I am brand new to php - and to MySQL.
I have loaded a test table into the data base - and need to reproduce it into an HTML table. The problem is representative of a series of tables which will have varying numbers of rows and columns. I am trying to create a standard php script to handle that.
For the test table, I have found that the following code gives me a display that shows the bones of what I want - but not with the results in an HTML table
<?php
$username = "#$!#$!#*$!";
$password = "yyyyyyyyy";
$hostname = "zzzzzzzzz";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_select_db("aaaaaaa") or die ("Unable to select database!");
$query = "SELECT * FROM tablename";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
while ($row = mysql_fetch_row($result))
{
echo "$row[0]",":";
echo "$row[1]",":";
echo "$row[3]" ,":";
echo "$row[4]" ,":";
echo "$row[5]" ,":";
echo "$row[6]" ,":";
echo "$row[7]",":";
echo "$row[8]",":";
echo "$row[9]" ,":";
echo "$row[10]",":";
echo "$row[11]" ,":";
echo "$row[12]";
echo "<br>";
}
mysql_close($dbh);
?>
Of course, "." appeared in echo so that I could see what was going on.
I cannot figure how to get the data from each field of each row into an HTML table handling each column and row. I'd be grateful if someone could point me at a suitable link, or give me a quick steer, to do that.