Code help

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
I'm trying to code something for the section that shows the users badges on the homes page I have

The following code is the default one
PHP:
<?php
$badges = dbquery("SELECT * FROM user_badges WHERE user_id = '$id' ORDER BY user_id DESC");
$badge = $badges['badge_id'];
if(mysql_num_rows($badges) == 0)
{
    echo"$username has no badges";
}
else
{
    while($badge = mysql_fetch_object($badges))
    {
        echo"<img src=\"/r63/c_images/album1584/$badge->badge_id.gif\">";
    }
}
?>

but when I try edit it to this, it wont recognise the $badge->badge_id code
PHP:
<?php
$badges = dbquery("SELECT * FROM user_badges WHERE user_id = '$id' ORDER BY user_id DESC");
$badge = $badges['badge_id'];
if(mysql_num_rows($badges) == 0)
{
echo"$username has no badges";
}
else
{
while($badge = mysql_fetch_object($badges))
{
echo'<img class="tooltip" style="cursor:pointer;" title="$badge->badge_id !" src="r63/c_images/album1584/$badge->badge_id.gif" style="margin-right: 10px;float:left;" /> ';
}
}
?>

If you're wondering what the code is for I'll post an image below, its so when you hover over the badge you see the badge id, its just a cool effect, if anyone can help It'll be appreciated, im using UberCMS also
8b199844dcb0433495e058692ae1601b.png

 
nvm I got it working with the following code
Code:
 <?php

    $getBadges = dbquery("SELECT * FROM user_badges WHERE user_id = '$id' ORDER BY user_id DESC");
       
?>

                <center><?php
    while($b = mysql_fetch_assoc($getBadges)){
                echo '<img class="tooltip" style="cursor:pointer;" title="' . $b['badge_id'] . '" src="http://198.50.211.213/r63/c_images/album1584/' . $b['badge_id'] . '.gif" style="margin-right: 10px;float:left;" />';
}
    ?>
Can a mod close the thread please
 

Users who are viewing this thread

Top