jakebur01 Posted March 9, 2009 Share Posted March 9, 2009 My table for displaying members has been working ok when querying all members. I have been trying to add an extra loop that will make the table only display members that are friends of a specific member. My problem is that it is grabbing the same member twice. For example if Fred is UserId1 and Tom is UserId2, then row 2 Joe is UserId1 and Fred is UserId2. It will display Fred twice. Also, I cannot get my <tr>'s to work correctly. echo '<table width="100%" border="0">'; $getimages = mysql_query("SELECT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved'", $db); if(!$getimages) die("Cannot execute query. " . mysql_error()); $countRows = mysql_num_rows($getimages); $i = 0; if ($countRows > 0) { while ($rowimages = mysql_fetch_assoc($getimages)) { $result = mysql_query("SELECT Username, Company, Country, State, Link FROM life_useraccount WHERE (`Username`='$rowimages[userId1]' OR `Username`='$rowimages[userId2]') ", $db) or die(mysql_error()); if ($i % 3 == 0) echo ($i > 0? '</tr>' : '') . '<tr>'; while ($myrow = mysql_fetch_array($result)){ //$id=$myrow["Id"]; echo '<td><center><div class="product"><a href="profile.php?q='.$myrow['Username'].'"><img src="'.$myrow['Link'].'" width="145" border="0" /></a></div><b>'.$myrow["Company"].'</b><br />'.$myrow["State"].'<br />'.$myrow["Country"].'</center></td>'; } if ($i == $countRows - 1) echo '</tr>'; $i++; } } echo '</table>'; Quote Link to comment https://forums.phpfreaks.com/topic/148557-solved-trouble-with-table/ Share on other sites More sharing options...
jakebur01 Posted March 9, 2009 Author Share Posted March 9, 2009 I tried using DISTINCT, but that did not do the trick. SELECT DISTINCT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved' Quote Link to comment https://forums.phpfreaks.com/topic/148557-solved-trouble-with-table/#findComment-780114 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.