Jump to content


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


My setup must be so wrong please lend a hand

Recommended Posts

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.
[code]$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 .= "
<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>

Share this post

Link to post
Share on other sites
What output are you expecting and what are you seeing?  ARe you expecting

[code]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[/code]

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.

Share this post

Link to post
Share on other sites
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.
[code]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[/code]

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.

Share this post

Link to post
Share on other sites


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.