Hi There! I am trying to script a simple dynamic drop down menu showing the tables that exist within my database using PHP 5. I currently have 2 tables installed in my MySQL database.
I have managed to run the script without problem with the menu showing up on my browser however the menu shows 2 entries but they have no words! The menu just contains 2 blank entries once I click the arrow button.
The script is shown below:
<?php
include "db_connect.php";
{
?>
<td valign=top><strong>Name:</strong></td>
<td>
<?php
echo "<select name=\"name\">";
echo "<option size =30 selected>Select</option>";
$result = mysql_query("show tables");
if(!$result) trigger_error("Query Failed: ". mysql_error($db), E_USER_ERROR);
if(mysql_num_rows($result))
{
while($table_array = mysql_fetch_assoc($result))
{
echo "<option>$table_array[0]</option>";
}
}
else
{
echo "<option>No Names Present</option>";
}
}
?>
</td>
Please do help pr give suggestions. Thanks.
Originally asked by: JavaNoob on Stack Overflow


Answers