Jump to content


Photo

My setup must be so wrong please lend a hand


  • Please log in to reply
3 replies to this topic

#1 presso

presso
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 October 2006 - 06:42 AM

ok the following code works , well works for pulling the info , well at least i think it does. I know my code is a little whacky as has been pointed out but it comes from within another module hence the layout. Anyway the second query's output works perfect and displays as it should but the first query just seems to display the same values for all 10 lines. Is it the way that i have the querys ect set out. Some helpful advice on this would be so welcome as its fustrating the hell out of me.
$query = $DB->query("SELECT name, date, regdate FROM users ORDER BY regdate DESC LIMIT 10");
while ($info = $DB->fetch_row($query)){
$name1 = $info['name'];
$date1 = $info['date'];

$query = $DB->query("SELECT subject, lastposter, views, replies, lastpost FROM thread ORDER BY lastpost DESC LIMIT 10");
while ($info1 = $DB->fetch_row($query)){
$ctoff = "35";
$subject = info1['subject'];
$lastposter = info1['lastposter'];
$views = info1['views'];
$replies = info1['replies'];
if (strlen($subject) > $ctoff) {
			$subject = substr($subject,0,$ctoff);
			$subject .= "...";
			}
			
$content .= "
<tr>
	<td class=\"sidedash\" align=\"left\"  >$name1</td>
	<td class=\"sidedash\" align=\"right\" >$date1</td>
	<td class=\"sidedash\" align=\"left\"  >$subject</td>
	<td class=\"sidedash\" align=\"left\"  >$lastposter</td>
	<td class=\"sidedash\" align=\"right\"  >$views</td>
	<td class=\"sidedash\" align=\"right\"  >$replies</td>
	</tr>";
	}
}


#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 23 October 2006 - 07:44 AM

What output are you expecting and what are you seeing?  ARe you expecting

Fred 1/1/01 Blah!  Fred  2  2
Fred 1/1/01 Glerp  Fred  1  0
John 2/2/02 Blah   Fred  5  1
John 2/2/02 Fnord John  7  1

But instead you are getting the same user on threads that belong to another user?  Judging by your code structure, you would be expecting results like the above.

#3 presso

presso
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 October 2006 - 09:12 AM

yes what you are showing is what i am expecting however that does not seem to be the case. this is more like what i am getting.
Fred 1/1/01 thread4  Fred  2  2
Fred 1/1/01 thread3  Fred  1  0
Fred 1/1/01 thread2   Fred  5  1
Fred 1/1/01 thread1  John  7  1

The output of thread4 fred 2 2 ect, is fine and what i am expecting , however the first query is outputing the same data.
If i swap the querys around the first one displays the output correct and the second one displays the last line of the result 10 times.

Can you see what i mean. I find it fustrating. I have tried every combination of moving the curly brackets as i thought they were causing the problem , but it either makes no difference or i get no output at all.



#4 presso

presso
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 October 2006 - 09:02 PM

any takers at resolving this fustrating issue ??




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users