Jump to content

[SOLVED] trouble with table


jakebur01

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

Archived

This topic is now archived and is closed to further replies.

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