Jump to content

While issues..


lordphate

Recommended Posts

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 :P]

 

    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:

 

phpfreaks.jpg

Link to comment
https://forums.phpfreaks.com/topic/143430-while-issues/
Share on other sites

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

Archived

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

×
×
  • 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.