devknob Posted July 8, 2007 Share Posted July 8, 2007 I have 2 tables, one of them is 'friends' another is 'users' I need to pull * from friends and attach 1 corresponding column from the users table to identify a picture. Tried this $sql = "SELECT msgs.pid, msgs.uid, msgs.run, users.di FROM msgs,users WHERE msgs.pid='$id'"; but thats doing some strange stuff.. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/58924-mysql-2-tables/ Share on other sites More sharing options...
wildteen88 Posted July 8, 2007 Share Posted July 8, 2007 What is the "strange stuff". Also could you post the table structures for mesgs and users table. Quote Link to comment https://forums.phpfreaks.com/topic/58924-mysql-2-tables/#findComment-292414 Share on other sites More sharing options...
devknob Posted July 8, 2007 Author Share Posted July 8, 2007 Strange stuff being the wrong images listed several times Here is the php <? //CHECK FOR FRIENDS include('connection.php'); $sql = "SELECT msgs.pid, msgs.uid, msgs.run, users.di FROM msgs,users WHERE msgs.pid='$id'"; $rs = mysql_query($sql,$conn); $numfr = mysql_num_rows($rs); ?> <tr> <td bordercolor="#000000" bgcolor="#E0DFE3" class="style5"> <?php print $ftit; ?> , Showing <? print $numfr; ?> <span class="style1">- <a href="#">View All</a></span></td> </tr> <tr> <td bordercolor="#000000" bgcolor="#FFFFFF" class="style5"></td> </tr> </table> <? while($row = mysql_fetch_object($rs)){ $pid = $row->pid; $usr = $row->uid; $img = $row->di; $usrna = $row->run; if($usr != 0){ if($img == 0){ $img = 1; } print "<a href=\"profile.php?id=$usr\"><img src=\"pix/tn/$img.jpg\"><br>" . $usrna . "</a>"; $img = 0; } } Heres the tables msgs (this is where friends are) id|pid|uid|run users (this is where the img number is) id|userdata|di| Quote Link to comment https://forums.phpfreaks.com/topic/58924-mysql-2-tables/#findComment-292429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.