note 4096 modified in function.odbc-fetch-row by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 Jun 2010 15:19:19 +0000 |
| Subject: | note 4096 modified in function.odbc-fetch-row by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170448@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.
<?php
$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);
?>
--was--
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://php.net/manual/en/function.odbc-fetch-row.php