I am extracting some data from an odbc datasource and presenting in a table.
How can I automatically extract the number of column and their headings, and then print them at the top of the table.
How can I automatically extract the number of column and their headings, and then print them at the top of the table.
Code:
<?php
//connect to the database
$connectionstring = odbc_connect("timeandfees_db", "", "");
//Define SQL query
$Query = "SELECT clientkey, coyname FROM clients WHERE (clientkey LIKE 'AC%') ORDER BY ClientKey";
//execute query
$queryexe = odbc_do($connectionstring, $Query);
$num = better_odbc_num_rows($connectionstring,$Query);
echo $num;
//query database
while(odbc_fetch_row($queryexe))
{
$clientkey = odbc_result($queryexe, 1);
$coyname = odbc_result($queryexe, 2);
//format results
print ("<tr>");
print ("<td>$clientkey</td>");
print ("<td>$coyname</td>");
print ("</tr>");
}
//disconnect from database
odbc_close($connectionstring);
?>