Page 1 of 1

outputting query result by"while"but one row lost

Posted: Sun Apr 29, 2007 6:24 am
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...

Posted: Sun Apr 29, 2007 6:33 am
by mentor
Remove this

Code: Select all

$row = mysql_fetch_row($result);

Posted: Sun Apr 29, 2007 6:41 am
by juline
yes, that's it. many thanx....