Re: Multiple 'similar' dropdowns -> 1 query
- From: Geoff Berrow <blthecat@xxxxxxxxxxx>
- Date: Wed, 27 Jul 2005 20:40:41 +0100
I noticed that Message-ID:
<1122490398.862551.269070@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> from frizzle
contained the following:
>Hmm, could you maybe explain a little bit more?
>I'm not trying to find a better way for the '$selected'-part,
>but i'm not able (yet) to create the same dropdown three
>times from 1 query ...
If you are doing something more than once you need to be thinking
'function'
Let is say you query the database and do a loop to put the values in an
array. In the following function, $name is the name of the select box,
$array is the array from the database and $sel is the selection you are
testing.
function mk_select($name,$array,$sel){
$string = "<select name=\"$name\"class=\"input\">";
foreach ($array AS $key=>$value) {
if($key==$sel){$selected=" selected";}
else{$selected="";}
$string .= "<option
value=\"$key\"$selected>$value</option>\n";
}
$string.="</select>";
return $string;
}
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
.
- Follow-Ups:
- Re: Multiple 'similar' dropdowns -> 1 query
- From: frizzle
- Re: Multiple 'similar' dropdowns -> 1 query
- References:
- Multiple 'similar' dropdowns -> 1 query
- From: frizzle
- Re: Multiple 'similar' dropdowns -> 1 query
- From: Geoff Berrow
- Re: Multiple 'similar' dropdowns -> 1 query
- From: frizzle
- Multiple 'similar' dropdowns -> 1 query
- Prev by Date: Interrupt session at configed time
- Next by Date: Re: How to kill process started by user?
- Previous by thread: Re: Multiple 'similar' dropdowns -> 1 query
- Next by thread: Re: Multiple 'similar' dropdowns -> 1 query
- Index(es):
Relevant Pages
|