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
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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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