Ah, hello my lord of falcons. This problem accurs as you haven't given $userid a value, as this makes me shiver i will help you as much as i can. I would sugguest you use $_SESSION['user']['id'] instead of $userid as it is already set in revcms, and this is only if you use revcms i think.
Oh lord of falcons try this code and see if it works.
PHP Code:
<?php
$getmybadges = mysql_query("SELECT badge_id FROM user_badges WHERE user_id = ".intval($_SESSION['user']['id']));
while($rowing = mysql_fetch_assoc($getmybadges)){
$badge = $rowing['badge_id'];
echo '<img src="{url}/game/c_images/badges/'.$badge.'.gif" style="margin-right: 10px;" />';
}
?>