note 4096 modified in odbc_fetch_row by ronabop
| From: | ronabop@php.net | Date: | Wed, 04 Oct 2000 15:21:09 +0000 |
| Subject: | note 4096 modified in odbc_fetch_row by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6052@lists.php.net to get a copy of this message | ||
Here is code snippet to do dynamically build a table so you do not have to hardcode the fields that
you wish to display. You could use the the odbc_result_all but this allows special handling of
rows/columns. This is similar to some ASP code I use.
$Fields = odbc_num_fields($cur);
print "<table border='1' width='100%'><tr>";
// Build Column Headers
for ($i=1; $i <= $Fields; $i++){
printf("<th bgcolor='silver'>%s</th>", odbc_field_name( $cur,$i));
}
// Table Body
$Outer=0;
while( odbc_fetch_row( $cur )){
$Outer++;
print "<tr>";
for($i=1; $i <= $Fields; $i++){
printf("<td>%s</td>", odbc_result( $cur, $i ));
}
print "</tr>";
}
print "</table>";
print "<b> Your request returned $Outer rows!</b>";
odbc_close( $cnx);
http://www.php.net/manual/function.odbc-fetch-row.php