lordphate Posted February 2, 2009 Share Posted February 2, 2009 Okay i KNOW this is something too simple, but i'm sick, and i've been looking at code for the last 14 hours [not this particular piece ] if($member) { $sql_query = "SELECT * FROM learning_forumthread WHERE idForum='".$idForum."'"; $result = mysql_query($sql_query,$conn); while($res = mysql_fetch_array($result)) { $sql_query2 = "SELECT * FROM learning_forummessage WHERE idMessage='".$res["last_post"]."'"; $result2 = mysql_query($sql_query2,$conn); while($row = mysql_fetch_array($result2)) { $res["post_title"] = $row["title"]; $res["post_time"] = $row["posted"]; $res["post_author"] = get_MemberName($row["author"]); }//while $res["forum"] = get_ForumName($idForum); $thread[] = $res; }//while }//if this is what it outputs: Link to comment https://forums.phpfreaks.com/topic/143430-while-issues/ Share on other sites More sharing options...
btherl Posted February 2, 2009 Share Posted February 2, 2009 What should the output be? And is the last post set for the final row of data from the first query? Link to comment https://forums.phpfreaks.com/topic/143430-while-issues/#findComment-752348 Share on other sites More sharing options...
lordphate Posted February 2, 2009 Author Share Posted February 2, 2009 it should be showing the results of $res["post_title"] = $row["title"]; $res["post_time"] = $row["posted"]; $res["post_author"] = get_MemberName($row["author"]); [which is almost identical to the one above]. It would be in the "Last Post" area. the last post comes from: while($res = mysql_fetch_assoc($result)) { ---this line--- $sql_query = "SELECT * FROM learning_forummessage WHERE idMessage='".$res["last_post"]."'"; $query = mysql_query($sql_query,$conn); while($row = mysql_fetch_array($query)) { also this is my updated code: if($member) { $sql_query = "SELECT * FROM learning_forumthread WHERE idForum='".$idForum."'"; $result = mysql_query($sql_query,$conn); while($res = mysql_fetch_assoc($result)) { $sql_query = "SELECT * FROM learning_forummessage WHERE idMessage='".$res["last_post"]."'"; $query = mysql_query($sql_query,$conn); while($row = mysql_fetch_array($query)) { $res["post_title"] = $row["title"]; $res["post_time"] = $row["posted"]; $res["post_author"] = get_MemberName($row["author"]); }//while $res["forum"] = get_ForumName($idForum); $thread[] = $res; }//while }//if same results as previous picture Link to comment https://forums.phpfreaks.com/topic/143430-while-issues/#findComment-752349 Share on other sites More sharing options...
lordphate Posted February 2, 2009 Author Share Posted February 2, 2009 Any ideas? Link to comment https://forums.phpfreaks.com/topic/143430-while-issues/#findComment-752525 Share on other sites More sharing options...
btherl Posted February 3, 2009 Share Posted February 3, 2009 I would start by echoing your queries, just to check they are what you expect. If they look ok, then display each of the result sets from each query like this: echo "<pre>"; var_dump($res); echo "</pre>"; That will format it nicely in html Link to comment https://forums.phpfreaks.com/topic/143430-while-issues/#findComment-753061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.