You are here: Re: [PHP] looping through an array problem « PHP « IT news, forums, messages
Re: [PHP] looping through an array problem

Posted by "Mark Cain" on 06/05/05 23:47

One way to do it is to change this :

$pub_sidebar[] = "<ul class='sidebar-menu'><a class='img-link'

to this:

$pub_sidebar[$cartoon['publisher_id']] = "<ul class='sidebar-menu'><a
class='img-link'

Mark Cain

----- Original Message -----
From: "Jack Jackson" <jackson.linux@gmail.com>
To: <php-general@lists.php.net>
Sent: Sunday, June 05, 2005 4:37 PM
Subject: [PHP] looping through an array problem


> This is something dumb I am doing but:
>
> Trying to pull all names of publishers in db. This sql:
>
> SELECT art.art_id,art.publisher_id,publisher.publisher_name,
> FROM art
> LEFT JOIN publisher
> ON publisher.publisher_id=art.publisher_id
>
> pulls (in phpmyadmin) four rows:
> artID pubID Publisher_name
> 1 7 The New York Times: Sunday Styles
> 2 3 The New York Sun
> 3 2 Metro NY
> 4 3 The New York Sun
>
>
> I'm trying to make a sidebar which will make links to each unique
> publisher name:
>
> while ($cartoon = mysql_fetch_assoc($result)) {
> $pub_sidebar[] = "<ul class='sidebar-menu'><a class='img-link'
> href='{$_SERVER['PHP_SELF']}?p={$cartoon['publisher_id']}'
>
title=\"{$cartoon['publisher_name']}\">{$cartoon['publisher_name']}</a></ul>
";
> }
>
>
> This prints:
> The New York Times: Sunday Styles
>
> The New York Sun
>
> Metro NY
>
> The New York Sun
>
>
> I'd like to stop the NY Sun from appearing twice! What have i missed here?
>
> Thanks in advance!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация