Help: Simple mysql php list/drop down menu...

Discussion in 'PHP' started by Skillman13, Nov 21, 2009.

  1. #1
    I'm new to this sort off php/html...

    I want the user to select a value from the drop down menu and then for it to save the value they picked, -to a variable. -Maybe when a submit button is clicked... The code I have so far is...

    <form id="form1" name="form1" method="post" action="">
    <select name="list" id="list">
    <?
    $result = mysql_query("SELECT * FROM `Tactics`");
    $numrows= mysql_num_rows($result);
    if($numrows >= 1) {
    while($row = mysql_fetch_row($result))
    {
    print("<option value=\"$row[0]\">$row[0]</option>");
    }
    } else {
    print("<option value=\"\">No options created yet</option>");
    }
    ?>
    </select>
    </form>

    Which gets values from mysql database and prints them out onto the drop down menu/listbox.

    Now what do I need to add for it to save their picked option as a varible? or $_POST[something]?

    This code is probably really simple, I just don't have knowledge yet...

    This is the button code by the way...

    <form id="form1" name="form1" method="post" action="">
    <input name="do_insert" type="hidden" value="TRUE" />
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </form>

    (I want it when that is clicked to save the $_POST['list1'] as a variable $list1...) :)

    Thanks alot,

    James
     
    Skillman13, Nov 21, 2009 IP
  2. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Anyone? =/
     
    Skillman13, Nov 21, 2009 IP
  3. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Never mind, found problem -the button needed to be in the same form. -Silly me :)
     
    Skillman13, Nov 21, 2009 IP