<html>
<title>ODBC PHP Test</title>
<body>
<p>This connects to an ODBC DSN through PHP and displays the information in a table.</p>
<hr>
<table width="75%" border="1" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF">
<tr bgcolor="#0000FF">
<td height="22"><b>Class ID</b></td>
<td height="22"><b>Class Name</b></td>
<td height="22"><b>Section</b></td>
</tr>
<?
// connect to a DSN "DEMODATA" with no user or password
$connect = odbc_connect("demodata", "", "");
// query the users table for name and surname
$query = "SELECT id,name, section FROM class";
//Prepare the statement
$result = odbc_prepare ($connect, $query);
// execute the query
odbc_execute($result);
// fetch the data from the database
while(odbc_fetch_row($result)){
$id = odbc_result($result, 1);
$name = odbc_result($result, 2);
$section = odbc_result($result, 3);
print ("<tr>");
print ("<td>$id</td>");
print ("<td>$name</td>");
print ("<td>$section</td>");
print ("</tr>");
}
// close the connection
odbc_close($connect);
?>
</table>
</body>
</html>