Need help with this line of code

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
Im trying to make it show on my user homes every group that the current user is in with the group badge and the name etc, this is the code I have but its not working, can someone give some assistance?
Code:
<?php
 
  $members1 = mysql_query("SELECT * FROM groups_members WHERE user_id = ''".$id."'");
   while ($members = mysql_fetch_assoc($members1))
   {
       $groupid = $members['group_id'];
      
       $ingroup = mysql_query("SELECT * FROM groups_data WHERE id = '".$groupid."'");
  while ($group = mysql_fetch_assoc($ingroup))
  {

     echo '<div class="badge-container-wrap"><div class="badge-container"><div class="badge-image" original-title="' . htmlspecialchars ($group['name']) . ' "><img border="0" src="http://localhost/habbo-imaging/badge/' . $group['badge'] . '.gif" class="tc" data-hasqtip="1445" oldtitle="HFFM Disco Weekend" title="" aria-describedby="qtip-1445"></div></div></div>';
   
}
}

?>
 

JayC

Always Learning
Aug 8, 2013
5,497
1,398
There's no reason to have another while loop. Clean your code up:
PHP:
<?php
$groupMembers = mysql_query("SELECT * FROM `groups_members` WHERE `user_id` = ''".$id."'");
while ($groupStuff = mysql_fetch_assoc($groupMembers))
{
$theGroupID = $groupStuff['group_id'];
$groupData = mysql_fetch_assoc(mysql_query("SELECT * FROM `groups_data` WHERE `id` = '".$theGroupID."'"));
echo '<div class="badge-container-wrap"><div class="badge-container"><div class="badge-image" original-title="' . htmlspecialchars ($groupData['name']) . ' "><img border="0" src="http://localhost/habbo-imaging/badge/' . $groupData['badge'] . '.gif" class="tc" data-hasqtip="1445" oldtitle="HFFM Disco Weekend" title="" aria-describedby="qtip-1445"></div></div></div>';
}
?>
 

Users who are viewing this thread

Top