php - Two queries to get information -


i have 2 data tables. 1 contains of users identifiable informaiton (username, id, etc) , rest content generated them. doing comments page. when submit comment, user_id goes in comment. on comments page doing query show of comments have use user_id comments pull name user_database. using query below no success. how can tweak it?

code:

   $query="select * comments post_id = '$postid'";      $result=mysql_query($query);     $num=mysql_numrows($result);     mysql_close();     echo "";     $i=0;    while ($i < $num) {     $comment=mysql_result($result,$i,"comment");    $user_id=mysql_result($result,$i,"user_id");    $other=mysql_result($result,$i,"other");       echo "<br>$comment, $user_id, $other";      echo "";      $i++;     }       if(mysql_num_rows($result) < 1) {       echo "<div id=noresultfound>no results $comment</div>";        } 

to information 2 tables in single query, can use join:

select     c.userid,     c.comment,     u.username,     ...etc... comments c join user_database u on c.user_id = u.user_id post_id = '42' 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -