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");

if(mysql_num_rows($mysql_result))
{


$h = 0;
$i = 1;

while ($row=mysql_fetch_array($mysql_result));
{

if  ($i == 1)
{
 //this only happens once since $i has the value 1 here only.
$CuisineMenuArray[0] = $row[0];
}
 //this checks the next instance in $row against the previous instance in
$CuisineMenuArray.  If they are not the same, it adds what is in $row to
thenext position in $CuisineMenuArray.  If theyare the same it just skips to
the next instance in $row and checks it against the last instance in
$CuisineMenuArray again.
if ($row[$i] != $CuisineMenuArray[$h])
{
$CuisineMenuArray[$h+1] = $row[$i];
echo "$CuisineMenuArray[$h]";
echo "$row[$i]";

$h = ($h + 1);
$i = ($i + 1);
}
else
{
$i = ($i + 1);
}
}
}


?>

Scott Stinsman
Academic Coordinator
General Internal Medicine
1215 Blockley Hall
423 Guardian Drive
Philadelphia, PA  19104-6021
(phone)  215-662-7623
(fax)  215-349-5091
(email)  [EMAIL PROTECTED]


-- 
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