I am working on the following code where the user chooses a table from a dropdown. On change, it displays the table but at the moment it is echoing some of the code to screen.
<?php
$dbh = "localhost";
$dbn = "dbname";
$dbu = "dbuser";
$dbp = "dbpassword";
$conn = mysql_connect($dbh,$dbu,$dbp) or die("Unable to connect do database.");
mysql_select_db($dbn, $conn) or die("Unable to select database.");
$result = mysql_query("SHOW TABLES FROM $dbn") or die("Cannot list table names.");
echo "
<form name=\"table_browser\" action=\"".$PHP_SELF."\" method=\"GET\" >
<select name=\"t\" onChange=\"javascript:submit();\">
<option>Select a table</option>
";
while ($row = mysql_fetch_row($result)){
echo " <option value=".$row[0].">".$row[0]."</option>
";
}
echo " </select>
</form>
";
if (!isset($t)){
die("Please select a table");
}
?>