Help With Drop Down Menu

Discussion in 'PHP' started by ladieballer2004, Aug 25, 2009.

  1. #1
    So i'm totally new at this. I have a field in my form that asks the user what Grade he or she is in but i don understand how to pass that answer into my database. Can anyone help?
    
    <form action="insert.php" method="POST">
      <select name="Class" id="Class" onchange="MM_jumpMenu('parent',this,0)">
        <option>Select</option>
        <option>Freshman</option>
        <option>Sophomore</option>
        <option>Junior</option>
        <option>Senior</option>
        <option>item1</option>
      </select>
    </form>
    
    Code (markup):

     
    ladieballer2004, Aug 25, 2009 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    What is the code in insert.php? If it has the code to connect to the database and insert/update the table, you are done.
     
    prasanthmj, Aug 25, 2009 IP
  3. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    insert.php should contain something like this:

    mysql_connect(localhost,'username','paassword');
    @mysql_select_db('dbname') or die( "Unable to select database");
    PHP:
    get the values form the form:

    $class = $_POST['Class']
    PHP:
    insert into db:

    mysql_query("INSERT INTO students (class) VALUES ($class)");
    PHP:
     
    superdav42, Aug 25, 2009 IP