Re: creating a drop down menu from mysql categories
| From: | chad kellerman | Date: | Thu, 14 Mar 2002 18:09:39 +0000 |
| Subject: | Re: creating a drop down menu from mysql categories | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17689@lists.php.net to get a copy of this message | ||
Thanks everyone for the help,
I know with other lists, sometimes when you finally get you problem to work you post your
answer. Anyway, just in case anyone was wondering, here is what I ended up doing:
<?
mysql_connect("localhost","$user","$pass");
mysql_select_db("$db");
$query = "SELECT category_ID,category_name FROM tblCategories";
$result = mysql_query($query);
?>
<td>category</td>
<td><select size="1" name="category_name">
<?
while ($category_array = mysql_fetch_array($result)) {
print
"<optionvalue=$catergory_array[0].>$category_array[1]</option>";
}
?>
</select></td>
I had it in a table. anyway thank alot.
-chad
On Thu, 14 Mar 2002 07:46:36 -0500
chad kellerman <ckellerman@alabanza.com> wrote:
> Hello everyone,
>
> I am a little new to the list. I have been reading a lot of the posts but have not
> submitted yet. But I ran into a problem I was hoping I might get e little help or at least get a
> point in the right direction.
>
>
> I have a table called tblCategories with field category_ID with is auto_incremented and
> another field called category_name.
>
> I wish to have a drop down menu on an html page that is generated automatically with
> Category_name as the option and the option value=category_ID. It is going in a form which I submit
> and adds to a mysql database. Everything is working fine except I cannot create the drop down menu
> out of php. I would rather not have to edit my html page when ever I add a category.
>
> Is there any place I can look to see how someone else has accomplished this? Or is there
> any specific function I should research in the php.net manual pages? I have been looking but not
> too successfull.
>
> thank you for any help you can offer.
>
>
> -chad
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>