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: Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
lordphate Posted February 2, 2009 Author Share Posted February 2, 2009 Any ideas? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.