FROM THE MANUAL:
mysql_fetch_row() fetches one row of data from the result associated with
the specified result identifier. The row is returned as an array. Each
result column is stored in an array offset, starting at offset 0. 

Therefore:
    print("<option value=\"$row[0]\">$row[0]</option>\n");

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 10:10 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Drop Down Menus


Hi wonder if anyone knows what I am doing wrong here.

I have a drop down selection menu that is generated from a mysql database.
In the database we have over 15 fields one of them contains text for the
catergory that the entry belongs to. I have used the following code to
generate my drop down menu but when i view it in the browser the drop down
menu has not listed the categories instead we have blank entries for each
selection.

<? mysql_connect("localhost","user","password");
    mysql_select_db("database");
    $sql = "select distinct category from books ORDER BY category ASC";
    $makes_result = mysql_query($sql);
    print ("<select name=\"category\">\n");
    print("<option selected value=\"\">Please select a
Category</option>\n");
    while($row = mysql_fetch_row($makes_result))             
    {
    print("<option value=\"$row[1]\">$row[1]</option>\n");
    }
    print("</select>"); ?>

Thanks for the help.

Barry

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to