outputting query result by"while"but one row lost

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
juline
Forum Commoner
Posts: 37
Joined: Thu Jul 15, 2004 9:05 am

outputting query result by"while"but one row lost

Post by juline »

Hi,

i am using following script to output the result, but one data row is always missing. E.g. there are 3 results for the query, but only 2 are being displayed.

Code: Select all

$result = mysql_query("SELECT * FROM ".$DBprefix."table ORDER BY customerid");
		
		if (!$result) {
			echo 'Query error: ' . mysql_error();
			exit;
		}
		
		$row = mysql_fetch_row($result);
		
		while ($row = mysql_fetch_array ($result))
		{
		echo("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='650'>
		  <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
                  </tr>");
		
			echo ("<tr><td>");
			echo $row[0];
			echo ("</td><td>");
			echo $row[3];
			echo ("</td><td>");
			echo $row[5];
			echo ("</td><td>");
			echo $row[4];
			echo ("</td><td>");
			echo $row[2];
			echo ("</td><td>");
			echo $row[1];
			echo ("</td></tr>");
		}
thanx in advance...
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

Remove this

Code: Select all

$row = mysql_fetch_row($result);
juline
Forum Commoner
Posts: 37
Joined: Thu Jul 15, 2004 9:05 am

Post by juline »

yes, that's it. many thanx....
Post Reply