acegames Posted July 4, 2009 Share Posted July 4, 2009 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 More sharing options...
Adika Posted July 4, 2009 Share Posted July 4, 2009 Just add this: $coms1 = mysql_num_rows(mysql_query("SELECT * FROM `blog` WHERE `id`='$bid'", $conn)); Under this line: $bid = $row["bid"]; $date = $row["date"]; Link to comment https://forums.phpfreaks.com/topic/164767-help-querying-2-tables/#findComment-868885 Share on other sites More sharing options...
acegames Posted July 4, 2009 Author Share Posted July 4, 2009 Thanks for the quick reply but I tried that and I just get a value of zero Link to comment https://forums.phpfreaks.com/topic/164767-help-querying-2-tables/#findComment-868893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.