Need help with some Code

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
This is a code to fetch badges for a staff page but the problem I have is it doesnt choose the 5 Im wearing, it chooses 1 or 2 of them and displays that badge, 2 or 3 times so for example, Im wearing 5 different badges but on staff page, badge 1 is showing up twice and badge 2 is showing up 3 times, can anyone help?
PHP:
$query_badges = Core::$DB->prepare("SELECT * FROM user_badges WHERE user_id = '".$rank_user['id']."' AND badge_slot > 0 ORDER BY badge_slot LIMIT 5")->execute();
                if($query_badges->num_rows == 0)
                {    
                    self::$staff_containers = self::$staff_containers.'<div><i><ubuntu>'.Template::$language['have_no_badges'].'</ubuntu></i></div>';
                }

                while($badges = $query_badges->fetch_assoc()){
                    self::$staff_containers = self::$staff_containers.'<img style="margin-top: -5px; margin-bottom: 5px; margin-right: 10px; float: left;" src="'.Core::$Config['badge']['url'].$badges['badge_id'].'.gif">';
                }

                self::$staff_containers = self::$staff_containers.'
                        </div>
                       
                    </div>
                ';
            }
 

Spoderman

y u do dis 2 me
Jun 30, 2013
209
37
Try this code:
PHP:
 $getBadges = mysql_query("SELECT * FROM user_badges WHERE user_id = '" .$member['id'] . "' AND badge_slot >= 1 ORDER BY badge_slot DESC LIMIT 5");
                                    
                                        while ($b = mysql_fetch_assoc($getBadges))
                                        {
                                                echo '<img src="/r63/c_images/album1584/' . $b['badge_id'] .'.gif" style="float: left;">&nbsp;&nbsp;&nbsp;';
 

Users who are viewing this thread

Top