Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 7 of 7

Thread: PHP Help

  1. #1
    Join Date
    Feb 2008
    Posts
    291
    Tokens
    0

    Default PHP Help

    Well, I have 2 questions to do with PHP.

    For my mafia game im making, I need to sort out 2 things.

    1. Im making better crimes for you when you get to a certain rank, Ect bodyguard. So how would I make it so that the link appears when your bodyguard+. Also, How would I make it so that if your not bodyguard and you try and get onto the page it says You are not the required rank!

    2. For my Newspaper control panel, how would I make it say you are not an editor if editor=0, as if editor=1 you will be an editor.

    Please help

  2. #2
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Well, i know simple php so id do this:

    <?php
    session_start();
    include("config.php");
    $username = $_SESSION['username'];
    $check = mysql_query("SELECT * FROM `staff` WHERE `username`='$username'") or die (mysql_error());
    $get = mysql_fetch_array($check);
    if($get[rank] == "bodyguard"){
    ?>
    PUT CODE U WANNA SHOW IF THEIR RANK IS BODYGUARD HERE
    <?}else{ echo("Error, you aint a bodyguard!!"); }?>
    For the editor bit, its the same..

    <?php
    session_start();
    include("config.php");
    $username = $_SESSION['username'];
    $check = mysql_query("SELECT * FROM `staff` WHERE `username`='$username'") or die (mysql_error());
    $get = mysql_fetch_array($check);
    if($get[editor] == "1"){
    ?>
    PUT CODE U WANNA SHOW IF THEIR RANK IS EDITOR HERE
    <?}else{ echo("Error, you aint an editor!!"); }?>
    Its just a simple way, there are other and ppl will probs flame me for this but yeah.

    Lew.

  3. #3
    Join Date
    Feb 2008
    Posts
    291
    Tokens
    0

    Default

    Thanks

  4. #4
    Join Date
    Feb 2008
    Posts
    291
    Tokens
    0

    Default

    Doesnt work. I forgot to mention I only want the 1st question for a section in a menu

  5. #5
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    It basically works the same way...

    <?php
    session_start();
    include("config.php");
    $username = $_SESSION['username'];
    $check = mysql_query("SELECT * FROM `staff` WHERE `username`='$username'") or die (mysql_error());
    $get = mysql_fetch_array($check);
    if($get[rank] == "bodyguard"){
    ?>
    PUT IMAGE OR DIV HERE FOR BODY GUARD NAVIGATION BUTTON
    <?}?>

  6. #6
    Join Date
    Feb 2008
    Posts
    291
    Tokens
    0

    Default

    I dont think you get me.

    EDIT: Also, what would I put for the query and the fetch bit. The 'rank' table is in the 'players' database.

    This is a section in my menu of my game:

    <br />
    <table align="center" width="100%" class="tbl">
    <tr><td align="center" class="hdr">.::Crime Scene::.</td></tr>
    <tr><td align="left" class="tbl">
    &nbsp;<a href="kill.php" target="main">Kill</a><br />
    &nbsp;<a href="bf.php" target="main">Bullet factory</a><br />
    &nbsp;<a href="crime.php" target="main">Crimes</a><br />
    &nbsp;<a href="gta.php" target="main">Car theft</a><br />
    &nbsp;<a href="bta.php" target="main">Boat theft</a><br />
    &nbsp;<a href="extortion.php" target="main">Extortion</a><br />
    &nbsp;<a href="garage.php" target="main">Garage</a><br />
    &nbsp;<a href="dock.php" target="main">Dock</a><br />
    &nbsp;<a href="drugs.php" target="main">Drugs</a><br />
    &nbsp;<a href="bank.php" target="main">Bank</a><br />
    &nbsp;<a href="atm.php" target="main">ATM</a><br />
    &nbsp;<a href="mission.php" target="main">Missions</a><br />
    &nbsp;<a href="oc.php" target="main">OC</a><br />
    </td></tr>
    </table>
    <br />

    Say If I wanted to make that section for bodyguards only, what would I put above that section. For my admincp bit, iv got above it: <? if ($a['level'] == "3"){ ?>
    Then nothing else and it works. So It would be nearly the same to have it as a rank. So what would I put? I need just the one line of code.
    Last edited by -Adam; 04-11-2009 at 08:57 PM.

  7. #7
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    I don't think you are explaining yourself clearly.. But i think you mean something like this (its a switch function).. (probably not the best coding ever either)

    PHP Code:
    <?php
    function getRank($username){

        
    $sql "SELECT rank FROM rank WHERE username='{$username}'";
        
    $query mysql_query($sql) or die(mysql_error());
        
    $row mysql_fetch_array($query);
        
    $rank $row['rank'];

        switch (
    $rank) {
            case 
    "apprentice":
                
                echo(
    '<br />
                    <table align="center" width="100%" class="tbl">
                    <tr><td align="center" class="hdr">.::Crime Scene::.</td></tr>
                    <tr><td align="left" class="tbl">
                    &nbsp;<a href="kill.php" target="main">Kill</a><br />
                    &nbsp;<a href="bf.php" target="main">Bullet factory</a><br />
                    &nbsp;<a href="crime.php" target="main">Crimes</a><br />
                    &nbsp;<a href="oc.php" target="main">OC</a><br />
                    </td></tr>
                    </table>
                    <br />'
    );

                break;
            
            case 
    "bodyguard":
                
                echo(
    '<br />
                    <table align="center" width="100%" class="tbl">
                    <tr><td align="center" class="hdr">.::Crime Scene::.</td></tr>
                    <tr><td align="left" class="tbl">
                    &nbsp;<a href="kill.php" target="main">Kill</a><br />
                    &nbsp;<a href="bf.php" target="main">Bullet factory</a><br />
                    &nbsp;<a href="crime.php" target="main">Crimes</a><br />
                    &nbsp;<a href="gta.php" target="main">Car theft</a><br />
                    &nbsp;<a href="bta.php" target="main">Boat theft</a><br />
                    &nbsp;<a href="extortion.php" target="main">Extortion</a><br />
                    &nbsp;<a href="garage.php" target="main">Garage</a><br />
                    &nbsp;<a href="dock.php" target="main">Dock</a><br />
                    &nbsp;<a href="drugs.php" target="main">Drugs</a><br />
                    &nbsp;<a href="bank.php" target="main">Bank</a><br />
                    &nbsp;<a href="atm.php" target="main">ATM</a><br />
                    &nbsp;<a href="mission.php" target="main">Missions</a><br />
                    &nbsp;<a href="oc.php" target="main">OC</a><br />
                    </td></tr>
                    </table>
                    <br />'
    );
                break;
        }
        
    }
    ?>
    and for usage do this:

    PHP Code:
    <?php
    getRank
    ("Blinger");
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •