Jump to content

having quite a bit of trouble with a simple php while mysql loop?


Recommended Posts

Hello,

 

some of the simplest things in code are the hardest for me... I've done this before but I can't remember how.

I have a mysql loop that fetches information from a table based on the username and then a loop inside of that one that fetches matches to the results based on an entry id... the problem is that the matching results are duplicated under under every match in the loop... please help?

 

$queryb = "SELECT * FROM database.field WHERE author = '".$user."' ORDER BY time DESC LIMIT 8";
$query_resultb = @mysql_query ($queryb) OR error(mysql_error(), __LINE__, __FILE__, 0, '', '');
while($infob = @mysql_fetch_array($query_resultb)) {
$eid = $infob['eid'];
$entry = info[*];
heres the matches... then I have another loop

$queryc = "SELECT * FROM database.comments WHERE id='".$eid."' ORDER BY time DESC LIMIT 2";
$query_resultc = @mysql_query ($queryc) OR error(mysql_error(), __LINE__, __FILE__, 0, '', '');
while($infoc = @mysql_fetch_array($query_resultc)) {

matches found here repeat for every $entry match above on the page inside the 1st loop??

}

}
  

 

I know this is a really easy fix... but I'm better at harder stuff when it comes to coding and always forget the simplest things that should just become second nature! I'm sure alot of other people have the same issues!

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.