echo("<select name='...'>")
while ($array = mysql_fetcharray($mysql))
{ echo("<option>{$array["catname"]}</option>");
}
echo("</select>")
that's the simple version - you may want to put the
whole lot inside ...
if (mysql_numrows())
{ ...
} else
{ echo("warning");
}
I may have got the function names wrong - I use an
abstraction layer these days
Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
----- Original Message -----
From: Steve Jackson <[EMAIL PROTECTED]>
To: PHP General <[EMAIL PROTECTED]>
Sent: Tuesday, December 10, 2002 3:24 PM
Subject: [PHP] How do I populate a select?
> How do I populate a select list with a list of category names from a DB?
> I can select the names using a query but how do I loop through them to
> display them in a select?
>
> My query below will return the cat names. (when I do something with it
> like echoing the result)
>
> $mysql = mysql_query("SELECT catname FROM categories ORDER BY catid");
>
> But I want to give each catname in the DB a unique name in a form select
> and don't know how to go about it.
> Tutorials or tips anyone?
> Regards,
>
> Steve Jackson
> Web Developer
> Viola Systems Ltd.
> http://www.violasystems.com
> [EMAIL PROTECTED]
> Mobile +358 50 343 5159
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php