why does this do this?

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

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

why does this do this?

Post by nigma »

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++)
			&#123;
				@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)
				&#123;
					print "<td>$this->col</td>";
				&#125;
				print '</tr>';
			&#125;
		&#125;
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

because mysql_fetch_array returns an array with both numerical and string-indexed elements.
try mysql_fetch_row instead
Post Reply