Re: Multiple 'similar' dropdowns -> 1 query



I noticed that Message-ID:
<1122495115.266022.14850@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> from frizzle
contained the following:

>Hmm, being the newbie i am, i still can't get it to work:
>i have $result = mysql_fetch_array($get_result);
>
>Works fine with a
>
>do{
> foo
>}while($result = mysql_fetch_array($get_result));
>
>It returns the following from the DB:
>
>id code
>____________
>27 ABC becomes: <option value="27">ABC</option>
>35 KNO becomes: <option value="35">KNO</option>
>57 TRE etc.
>81 FLO etc.
>____________
>
So $result[id] ==27 $result[code]==ABC

You have to combine those into a new array
$select_array=array();
while($result = mysql_fetch_array($get_result)){
$select_array[$result[id]]=$result[code];
}

Then your new array will contain the database rows as key/value pairs
and you can use it in the function.

echo mk_select('name_1', $select_array, 'find_this');
--
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/
.



Relevant Pages

  • Re: generic list constructor
    ... Foo foo = new Foo; ... It seems to me that the expression returns an array of Foo with ... hmm thanks, that works too - although i still don't really understand ... exactly why my original example was invalid ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Serialization with XmlSerializer: how to set the XML root node to something different from <
    ... Methods can return instances of Foo. ... If your method returns an array, then the attributes that apply are those on ... You are asking specifically about xml serialization, ...
    (microsoft.public.dotnet.xml)
  • Re: Static _Bool initialization
    ... The "&" operator will never yield a null pointer if its operand is ... If foo is an array of more than 42 elements, ... If the compiler (which can ...
    (comp.std.c)
  • Re: pointer usage in c
    ... > char *foo; ... I think my teacher wrong. ... Your array b is local to the function foo. ...
    (comp.lang.c)
  • Re: Returning a string array from a function
    ... I'd like to return an string array from a function so ... E.g. "total" only gets found out inside foo. ... to avoid storing past the end of the sptr[] array if `total' ...
    (comp.lang.c)