select box selections to database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sgawas01
    New Member
    • Feb 2008
    • 4

    select box selections to database

    I have many entries in list box.
    I am submitting form using post method to update.php.
    Now i want all the entries present in the list box and put them in the database table using mysql.
    please tell me the solution.
    Last edited by ronverdonk; Apr 2 '08, 01:50 PM. Reason: text sanitized
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by sgawas01
    II have many entries in list box.
    I am submitting form using post method to update.php.
    Now i want all the entries present in the list box and put them in the database table using mysql.
    please tell me the solution.
    Here's as much as im giving you for now:
    [php]
    <?php
    if(isset($_POST['submitIt']))
    {
    $_values = $_POST['listboxA'];
    foreach( $_values AS $_x)
    {
    echo $_x . "<br />";
    // here you would insert into database
    }
    }
    else
    {
    ?>
    <html>
    <head></head>
    <body>
    <form name="" action="" method="post">
    <select name="listboxA[]" size="3" multiple="true" >
    <option value="Option 1" selected>Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
    <option value="Option 4">Option 4</option>
    <option value="Option 5">Option 5</option>
    </select>
    <input type="submit" name="submitIt" >
    </form>
    </body>
    <?php
    }
    ?>
    [/php]
    Here's a tutorial for getting you started on mysql.

    Comment

    • sgawas01
      New Member
      • Feb 2008
      • 4

      #3
      Originally posted by markusn00b
      Here's as much as im giving you for now:
      [php]
      <?php
      if(isset($_POST['submitIt']))
      {
      $_values = $_POST['listboxA'];
      foreach( $_values AS $_x)
      {
      echo $_x . "<br />";
      // here you would insert into database
      }
      }
      else
      {
      ?>
      <html>
      <head></head>
      <body>
      <form name="" action="" method="post">
      <select name="listboxA[]" size="3" multiple="true" >
      <option value="Option 1" selected>Option 1</option>
      <option value="Option 2">Option 2</option>
      <option value="Option 3">Option 3</option>
      <option value="Option 4">Option 4</option>
      <option value="Option 5">Option 5</option>
      </select>
      <input type="submit" name="submitIt" >
      </form>
      </body>
      <?php
      }
      ?>
      [/php]
      Here's a tutorial for getting you started on mysql.


      Thanks For The Reply..

      Comment

      Working...