PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nigma
DevNet Resident
Posts: 1094 Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma » Sat May 31, 2003 1:29 am
Why does this method(the function is inside a class) print each column in the row twice?
Code: Select all
function PrintRows()
{
for ($this->counter = 0; $this->counter < $this->totalRows; $this->counter++)
{
@mysql_data_seek($this->result, $this->counter) or error("Unable to seek out row $this->counter.");
$this->data = mysql_fetch_array($this->result) or error("Unable to fetch array.");
print '<tr>';
foreach ($this->data as $this->col)
{
print "<td>$this->col</td>";
}
print '</tr>';
}
}
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Jun 01, 2003 1:08 pm
because mysql_fetch_array returns an array with both numerical and string-indexed elements.
try mysql_fetch_row instead