|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-21 21:05 UTC] ultrageek1 at hotmail dot com
[2009-11-22 00:45 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 16:00:01 2025 UTC |
Description: ------------ I loop through MYSQL data with a mysql_data_seek() and a while loop. and I loop through each row returned with a foreach() loop. function accepts a MYSQL resource as input ($data) along with an optional array of table headers ($head) which might only have one element. This is PHP 5.2.10, not .11 I would have to ask my hosting provider to upgrade the PHP version. no variables pass by reference. Reproduce code: --------------- <?php function build_table($data,$head = null){ echo "<table>"; if ($head){ foreach ($head as $h) echo "<th>".$h."</th>\n"; } if (is_resource($data)){ mysql_data_seek($data,0); while($row = mysql_fetch_array($data)){ echo "<tr>"; foreach($row as $cell){ echo "<td>".($cell)."</td>"; } echo "</tr>\n"; } echo "</table>\n"; } }?> Expected result: ---------------- head1 (head2 head3) r1d1 r1d2 r1d3 r1d4 r2d1 r2d2 r2d3 r2d4 r3d1 r3d2 r3d3 r3d4 .... Actual result: -------------- head1 (head2 head3) r1d1 r1d1 r1d2 r1d2 r1d3 r1d3 r1d4 r1d4 r2d1 r2d1 r2d2 r2d2 r2d3 r2d3 r2d4 r2d4 r3d1 r3d1 r3d2 r3d2 r3d3 r3d3 r3d4 r3d4 ....