Addressed to: "Stinsman, Scott" <[EMAIL PROTECTED]>
              [EMAIL PROTECTED]

** Reply to note from "Stinsman, Scott" <[EMAIL PROTECTED]> Wed, 7 Feb 
2001 16:00:29 -0500
>
> Hi everyone..been away and off the list for awhile.i am back to work and
> need some help.  I am not sure if I am having a problem with my PHP or
> mySQL.
> I have a table called "Restaurant" with a field called "Cuisine".  There are
> 5 records in this table.  When I run my code, it only returns one cuisine
> when there are 5.  I am trying to get all the Cuisines in the array called
> CuisineMenuArray with no duplicates so I can generate a drop-down menu of
> cuisines "on the fly".
>  Any help would be greatly appreciated!  Thanx.
>
> Here  is the code:
>
> <?php
> $db=mysql_connect("localhost", "*******", "********");
>
> mysql_select_db("quickcit", $db) OR DIE ("died at connect");
>
> $query = "SELECT Restaurant.Cuisine ";
> $query .= "FROM Restaurant ";
> $query .= "ORDER BY Restaurant.Cuisine ASC ";
> $mysql_result=mysql_query($query, $db) OR DIE ("died at query");
>

Try changing you Query to:

   SELECT DISTINCT Cuisine
   FROM Restaurant
   ORDER BY Cousine

Then rely on the DISTINCT to insure you only get one copy of the value
in your array.

while( list( $Couisine ) = mysql_fetch_row( $Result )) {
   $CouisineList[] = $Couisine;
   }

And you are done...




Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to