note 98504 deleted from mysqli-result.fetch-field by danbrown

From: Date: Sat, 19 Jun 2010 03:20:08 +0000
Subject: note 98504 deleted from mysqli-result.fetch-field by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170261@lists.php.net to get a copy of this message
Note Submitter: pharley64 at gmail dot com ---- public function table(mysqli_result $result) { echo "<table border='1'><tr>\n"; while($finfo = $result->fetch_field()) { $colnames[] = $finfo->name; } $c = count($colnames); //no function call at every iteration for($i=0; $i<$c; $i++) { echo "<th>" . $colnames[$i] . "</th>"; } echo "</tr>\n"; while($row = $result->fetch_assoc()) { echo '<tr>' ; for($j=0; $j<$c; $j++) { echo "<td>" . $row[$colnames[$j]] . "</td>"; } echo "</tr>\n"; } echo "</table>"; }

« previous php.notes (#170261) next »