Jump to content

Help Querying 2 tables


acegames

Recommended Posts

Hello I have 2 tables :

 

blog with , id , uid , title , entry , date

 

blog_comments with , id , uid , bid , date comment

 

With the following code I need to add a line to :

 

query the table blog to get the uid  where blog id = $bid

 

I have tried but cant get it to work at all and was hoping for some help

 

<?





$sql = mysql_query("SELECT * FROM `blog_comments` ORDER BY `date` DESC LIMIT 5;", $conn);

		while($row = mysql_fetch_array($sql)) {
			$comment = $row["comment"];
			$uid = $row["uid"];
                                $bid = $row["bid"];
			$date = $row["date"];
                                $coms = mysql_num_rows(mysql_query("SELECT * FROM `blog_comments` WHERE `bid`='$bid'", $conn));


$n = "navItem2";
print "<div class=\"$n\"><a href=\"profile.php?id=$uid\">" . Username($uid) . "</a> Said <a href=\"blog.php?a=3&bid=$bid&id=$blog\">$comment $blog $title</a> on " . MakeDate($date) . ";
		 	($coms Comments) </div>";
		}
?>

Link to comment
https://forums.phpfreaks.com/topic/164767-help-querying-2-tables/
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.