Jump to content

Recommended Posts

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>'; 

 

 

Link to comment
https://forums.phpfreaks.com/topic/148557-solved-trouble-with-table/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.