[thelist] Query selected

Andrew andrew at humanbehaviour.co.uk
Tue Mar 4 09:12:01 CST 2003


Hi Rich it doing things differently now :)  just needs a final tweak if you can
spot what it is that would be great.  It isn't diplaying what was previously
selected but it is working!  I've tried all the combination except the right one
:(

Actually as a matter of interest this function method?  Is it efficient to use
this method for a drop down as opposed to running the query from the same file?


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=\"CityID\">\n";
        if($selected == 0){
            print "<option value=\"City\" selected> -- SELECT AN OPTION --
</option>\n";
        }
        while($RowData = mysql_fetch_array($Result)){
            print "<option value=\"" . $RowData['CityID'] . "\"";
            if($selected == $RowData['CityID']){ print " selected"; }
            print ">" . $RowData['City'] . "</option>\n";
        }//END while
        print "</select>\n";
    }
} else {
    print "DATABASE QUERY ERROR!";
}//END if
}//END function CategoryDDmenu


Andrew
>




More information about the thelist mailing list