Hi
I'm new here and thought I could ask for help.
In my form, I want to select from a drop down list that holds the names of categories taken from my database. When selected, the name of the selected category will automatically populate a text field that is sitting empty next to the drop down list.
I have this code for the drop down list:
<?php
$sql = 'SELECT COUNT( * ) AS Rows , cat_name FROM wp_categories GROUP BY cat_name ORDER BY cat_name LIMIT 0, 30 ';
$result = mysql_query($sql);
if (!result)
{
echo "Could not run query" .mysql_error();
exit;
}
if (mysql_num_rows($result) == 0)
{
echo "No rows found";
exit;
}
print '<select name="categories">';
while ($row = mysql_fetch_assoc($result))
{
print "<option>$row[cat_name]";
}
print "</select>";
?>
Thanks for your help