[thelist] Query selected

Rich Gray rich at f1central.net
Tue Mar 4 08:55:01 CST 2003


> the query is the same only on a different page. it's not specific
> to a user.
>
> I tried this but it didn't work:
>
> function CategoryDDmenu($selected=0)
> {
> $Query = "SELECT City, CityID FROM city ORDER BY City";
> $Result = mysql_query($Query);
> if($Result){
>     if(mysql_num_rows($Result) <= 0){ print "NO RESULTS FOUND!"; }
>     else {
>         print "<select name=\"City\">\n";
>         if($selected == 0){
>             print "<option value=\"0\" selected> -- SELECT AN OPTION --
> </option>\n";
>         }
>         while($RowData = mysql_fetch_array($Result)){
>             print "<option value=\"" . $RowData['CityID'] . "\"";
>             if($selected == $RowData['City']){ print " selected"; }
>             print ">" . $RowData['City'] . "</option>\n";
>         }//END while
>         print "</select>\n";
>     }
> } else {
>     print "DATABASE QUERY ERROR!";
> }//END if
> }//END function CategoryDDmenu
> Andrew >

Andrew

I'm a bit late in on this thread but anyway... is the problem that the drop
down item is not selected?
If yes then I reckon this line ...

if($selected == $RowData['City']){ print " selected"; }

needs to be changed to ...

if($selected == $RowData['CityID']){ print " selected"; }

HTH
Rich




More information about the thelist mailing list