ID: 50259
User updated by: ultrageek1 at hotmail dot com
Reported By: ultrageek1 at hotmail dot com
Status: Open
Bug Type: MySQL related
Operating System: Linux
PHP Version: 5.2.11
New Comment:
I loop through the data with mysql_fetch_array() not with
mysql_data_seek() sorry.
Previous Comments:
------------------------------------------------------------------------
[2009-11-21 21:01:53] ultrageek1 at hotmail dot com
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
....
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50259&edit=1