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

Thread: Form Help.

  1. #1
    Join Date
    Oct 2006
    Location
    Merseyside
    Posts
    2,335
    Tokens
    0

    Latest Awards:

    Default Form Help.

    Ok I neeed a little help. I need to change this drop down menu to check buttons but need a little help.

    PHP Code:
      <select name="p_id">
        <?php
    $SQL 
    "SELECT * from options";
    $result mysql_query$SQL );
    while( 
    $row mysql_fetch_array$result ) ) {
    $id $row["ID"];
    $name $row["NAME"];
    ?>
        <option value="<?php echo $id?>"> <?php echo $name?></option>
        <?php ?>
      </select>
    How could I change that so that the options show up in a checkbox form method instead of a drop down menu.

    +REP to anyone who can help.

  2. #2
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    Use this for each of your checkboxes:

    PHP Code:
    <input type="checkbox" value="<?php echo $id?>" /><?php echo $name?>

  3. #3
    Join Date
    Oct 2006
    Location
    Merseyside
    Posts
    2,335
    Tokens
    0

    Latest Awards:

    Default

    Thanks got it.
    Last edited by Lilian; 11-05-2007 at 07:23 PM.

  4. #4
    Join Date
    Apr 2007
    Posts
    79
    Tokens
    0

    Default

    Ok Say I wanted That But They Cant TICK all at once? how..
    I NEED TO GIVE REP TO
    Heinous

    i found a cool Web site ts Stuff
    Click it


  5. #5
    Join Date
    Jan 2007
    Posts
    4,664
    Tokens
    1,279

    Latest Awards:

    Default

    Quote Originally Posted by Epanel View Post
    Ok Say I wanted That But They Cant TICK all at once? how..
    What you need are radio buttons if you want them only to check one, Check boxes are simply boxes that you can check where as radio buttons you can only select one option.

    Does this help?


  6. #6
    Join Date
    Dec 2006
    Location
    Kent, UK
    Posts
    627
    Tokens
    138
    Habbo
    Romanity

    Latest Awards:

    Default

    If you wanted them to be able to select more than one option...

    PHP Code:
    <?
    echo("<form>");
    $SQL "SELECT * from options";
    $result mysql_query$SQL );
    while( 
    $row mysql_fetch_array$result ) ) {
    $id $row["ID"];
    $name $row["NAME"];
    echo(
    "<input type='checkbox' name='box[]' value='$id'> $name");
    }
    (
    "</form>");
    ?>
    Then when submitted...
    PHP Code:
    $array $_POST[box];
    foreach(
    $array as $val){ //$val is the ID of each row
    //Whatever you want to do with each of the selected values

    Last edited by Romanity; 18-05-2007 at 07:25 PM.

Posting Permissions

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