Here's the PHP used to connect:
<?php
include ("dbvars.inc");
$global_dbh = mysql_connect($hostname, $username, $password);
mysql_select_db($db, $global_dbh);
function display_db_table($tablename, $connection)
{
$query_string = "select * from $tablename";
$result_id = mysql_query($query_string, $connection);
$column_count = mysql_num_fields($result_id);
print("<table border = 1>\n");
while($row = mysql_fetch_row($result_id));
{
print("<tr align=left valign=top>");
for($column_num=0; $column_num<$column_count; $column_num++)
print("<td>$row[$column_num]</td>\n");
print("</tr>\n");
}
print("</table>\n");
}
?>
and here's the function call within the html:
<?php display_db_table("country", $global_dbh); ?>
<?php display_db_table("city", $global_dbh); ?>
It seems to be connecting fine, but the html table cells that the function generates contain no data.
Here's the table structure for table city:
ID int(11) No auto_increment
countryID int(11) No 0
cityname varchar(50) No
And here's the data set:
ID countryID cityname
1 1 Chicago
2 1 Los Angeles
3 2 Montreal
Table structure for country:
ID int(11) No auto_increment
continent varchar(50) No
countryname varchar(50) No
Data set:
ID continent countryname
1 North America USA
2 North America Canada
I think I did everything ok, but something must not be right. Otherwise the tables would be showing up with something in them.
Any ideas?