So ive got a fully working page to display a dropdown list of all tables avaliable in my database. however i want it to display the list of all tables except one (as one of the tables contains user information which i dont want shown...) Is there a way to do this?
This is the section of the code ive got so far... $sql = "SHOW TABLES FROM $dbname"; $result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
if (mysql_select_db($dbname, $conn))
{
?>
<form method="post" action="Browse.php">
<select name="tables">
<?php
while ($row = mysql_fetch_row($result)) {
?>
<?php
echo '<option value="'.$row[0].'">'.$row[0].'</option>';
}
?>
</select>
<input type="submit" value="Show">
</form>
<?php
//mysql_free_result($result);
if (isset($_POST) && isset($_POST['tables']))
{
$tbl=$_POST['tables'];
//echo $_POST['tables']."<br />";
$query="SELECT * from $tbl ORDER BY title ASC";
$res=mysql_query($query);
//echo $query;
if ($res)
{
?>
<table border="1">
<?php
while ( $row = mysql_fetch_array($res))
{
echo "<tr>";
//echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
//echo "<td>".$row[2]."</td>";
//echo "<td>".$row[3]."</td>";
echo "</tr>";
} ?>
</table>
<?php
}
}
}
Its no biggie if there isnt an easy way to do so as i've figured out that by doing the $query="SELECT * from $tbl ORDER BY title ASC"; it wont display the data (as there isnt a title column in the user details table)..but i dont want the table name to be shown in the dropdown box
Just a general query really... Thanks