Jump to content

not all records are being displayed


bravo14

Recommended Posts

Because on line 30 you are calling mysql_fetch_assoc, which will pull the first result from the query. Then on line 38 for the while loop condition you are calling dbFetchAssoc(), which is a user defined defined function and is probabcalling mysql_fetch_assoc internally, which will then loop over the remaining results from the query.

 

Now each time mysql_fetch_assoc is called it increments the internal row counter by 1. When this happens the next row is returned from the result the next time mysql_fetch_assoc is called. This is why your code is always displaying one result less than what was returned from the query,

 

One fix would be to reset the internal row counter before the while loop using   mysql_data_seek(0);

 

Or echo the product name and description within the while loop when $i is zero. So remove lines 29 to 33 and add

		if($i === 0)
		{
			echo '<h1>'.$row['cat_name'].'</h1>'.$row['cat_description'];
		}

After the while loop construct -   while ($row = dbFetchAssoc($result)) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.