Hi.. wrote a script to print all the records from a database, but all I get is the header row of my table. My code:
<?
// Connect to db and test for failiure
if(!($dbLink = odbc_pconnect("db", "NC", "TEST")))
{
print("Failed to connect to database<BR>\n");
print("Aborting");
exit();
}
// Get everything from db
$Query = "SELECT * FROM Test";
$dbResult = odbc_exec($dbLink, $Query);
// Start table and header row
print("<table border=\"0\">\n");
print("<tr>\n");
print("<td bgcolor=\"#CCCCCC\"><b>ID</b></td>\n");
print("<td bgcolor=\"#CCCCCC\"><b>Name</b></td>\n");
print("<td bgcolor=\"#CCCCCC\"><b>Age</b></td>\n");
print("<td bgcolor=\"#CCCCCC\"><b>Location</b></td>\n");
print("<td bgcolor=\"#CCCCCC\"><b>Email</b></td>\n");
print("</tr>\n");
// Get each row
while(odbc_fetch_row($dbResult))
{
print("<tr>\n");
print("<td>$ID</td>\n");
print("<td>$Name</td>\n");
print("<td>$Age</td>\n");
print("<td>$Location</td>\n");
print("<td>$Email</td>\n");
print("</tr>\n");
}
// End table
print("</table>\n");
?>
What have I done wrong? The database is not empty, ie. there are actually records in it.
Help!! Thanx.