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 6 of 6
  1. #1
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default Little bit of PHP help! :)

    Hey!
    What im trying to acheive is this:
    I have a create user form, and i want for the person who is creating the user to be able to select a rank from a drop downlist and then insert it into a MySQL database.

    I can do this easily, but what i would like, to make things simpler later on, is that when the user selects say: Admin from the drop downlist and presses submit, the rank that is inserted into the database is '1' and Mod would be '2', its in my knowledge to edit this and insert into the database its just how would i make it so that the user can see 'Admin' but what is inserted is '1'

    Thanks for any help
    Callum
    Back for a while

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Code:
    <select>
        <option value="1">Admin</option>
        <option value="2">Mod</option>
    </select>

  3. #3
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Quote Originally Posted by Trinity View Post
    Code:
    <select>
        <option value="1">Admin</option>
        <option value="2">Mod</option>
    </select>

    How would i go about inserting that into my mysql database?
    Back for a while

  4. #4
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Quote Originally Posted by Trinity View Post
    Code:
    <select>
        <option value="1">Admin</option>
        <option value="2">Mod</option>
    </select>

    How would i go about inserting that into my mysql database?
    and thank you!

    Edit by Robbie! (Forum Super Moderator): Please do not double post within the time limit
    Last edited by Robbie; 04-04-2009 at 02:47 PM.
    Back for a while

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    PHP Code:
    <?php
    if($_POST) {
        
    $rank $_POST["rank"];
        
    mysql_query("INSERT INTO `stupid_table` (rank) VALUES('$rank')");
    }
    ?>

    <form name="test" method="post" action="test.php">
        <select name="rank">
            <option value="1">Administrator</option>
            <option value="2">Moderator</option>
            <option value="3">User</option>
        </select>
        
        <input type="submit" value="Add" />
    </form>
    If you selected "Administrator", it would be sent to $rank, and put in the database as "1".

  6. #6
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Ive sorted that now! Sorry i didntwant to triple post!

    Thanks for your help anyway!!
    Back for a while

Posting Permissions

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