Show badge at home.php

Results 1 to 3 of 3
  1. #1
    Novice Mitchel1993 is offline
    MemberRank
    Oct 2014 Join Date
    TilburgLocation
    2Posts

    config Show badge at home.php

    Hello,

    I was editing my home.php and wanted to show the badges there,
    but it won't show there. it's stays empty..

    I guess it's something with the $id.. but i'm not sure..
    and here is the code
    PHP Code:
    <?php


    $getmybadges 
    mysql_query("SELECT * FROM user_badges WHERE user_id= '$userid'");
                              


    while(
    $rowing mysql_fetch_assoc($getmybadges)){
    $badge $rowing['badge_id'];
    echo 
    '<img src="{url}/game/c_images/badges/'.$badge.'.gif" style="margin-right: 10px;" />';


    }
    ?>
    can someone please help me? (I have the whole home.php code if that's neccesary)


  2. #2
    Wanheda Funsolit is offline
    MemberRank
    Feb 2012 Join Date
    SwedenLocation
    259Posts

    Re: Show badge at home.php

    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;" />';


    }
    ?>

  3. #3
    Novice Mitchel1993 is offline
    MemberRank
    Oct 2014 Join Date
    TilburgLocation
    2Posts

    Re: Show badge at home.php

    Quote Originally Posted by Funsolit View Post
    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;" />';


    }
    ?>
    omg thanks, it worked haha, i'm not a good coder.. but thanks :)



Advertisement