Jump to content

not all records are being displayed


Go to solution Solved by 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)) {

Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.