I am trying to display the whole contents of a MySQL table using PHP. I want the code to display the table completely and it should work for any table that has been created in my database.
I have tried this, but it doesn't work.
<html>
<table>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
</tr>
<?php
require "config.php";
$strSQL = "SELECT * FROM MyGuests" or die(mysql_error($db));
$rs = mysqli_query($db, $strSQL);
while($row = mysqli_fetch_array($rs)) {
echo "\t<tr><td>".$row['col1data']."</td>
<td>".$row['col2data']."</td><td>".$row['col3data']."</td></tr>\n";
}
mysqli_close($db);
?>
</table>
</html>
It returns Col 1 Col 2 Col 3.