[thelist] Query selected
Rich Gray
rich at f1central.net
Tue Mar 4 10:05: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";
[chop]
Erm... without having seen the script that calls this function then I'd
guess that the '$selected' parameter is not being set or is zero when the
function is called the 2nd time ...
Check that when the script re-calls the function that the parameter passed
has the value of $_POST['CityID'] (I'm assuming you're posting the form
data...) so that the $selected == $Rowdata['CityID'] test in the function
returns true...
FWIW whether it is good to build the selector in a function ... well if you
build a city selection list in several places on your site then yes it is a
good idea, although I use a more abstract/generic function that builds
selection drop downs from any table which means I only need/code one
function that can be re-used on subsequent projects ... yep I'm lazy :)
Cheers
Rich
More information about the thelist
mailing list