On Wed, Apr 11, 2001 at 03:55:38PM -0600, Ashley M. Kirchner wrote:
> "Rodney J. Woodruff" wrote:
>
> > http://www.php.net/manual/en/function.msql-fetch-array.php
(snip)
> I need that result into the following:
> $items = array(0 => "Undefined", 1 => "Work", 2 => "Personal");
Here's a hint.
$arr[$key] = $value;
Define $key and $value from the row data that mysql_fetch_array
gives you.
> Reason is, I pass that $items variable to the following function:
>
> function MakeSelect($items, $selected) {
> $str = "";
> while(list($value, $name) = each($items)) {
> $str .= "<option value=\"$value\"" . ($value != $selected ? \
> ">" : " selected>") . "$name\n";
> }
> return $str;
> }
For the record, you're thinking about list() backwards. In your
function, the array keys will go into $value, and the values will go
into $name.
HTH,
Matt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]