Jump to content

[SOLVED] PHP mysql Array Handling.


dewey_witt

Recommended Posts

OK i have this form(below) that the value of the checked check boxes inserted into my mysql table in a feild called Arch. Any help will be apriciated :)

 

 <td><input name="Arch[0]" type="checkbox" value="Traditional">Traditional</td>
    <td><input name="Arch[1]" type="checkbox" value="Victorian">Victorian</td>
    <td><input name="Arch[2]" type="checkbox" value="Ranch">Ranch</td>
  </tr>
  <tr>
    <td><input name="Arch[3]" type="checkbox" value="Cottage">Cottage</td>
    <td><input name="Arch[4]" type="checkbox" value="Transistional">Transistinal</td>
    <td><input name="Arch[5]" type="checkbox" value="Log">Log</td>
  </tr>
  <tr>
    <td><input name="Arch[6]" type="checkbox" value="Cape Cod">Cape Cod</td>
    <td><input name="Arch[7]" type="checkbox" value="Dutch">Dutch</td>
    <td><input name="Arch[8]" type="checkbox" value="Contemporary"> Contemporary</td>
  </tr>
  <tr>
    <td><input name="Arch[9]" type="checkbox" value="Salt Box">Salt Box</td>
    <td><input name="Arch[10]" type="checkbox" value="Historical">Historical</td>
    <td> <input name="Arch[11]" type="checkbox" value="Chalet">Chalet</td>
  </tr>
  <tr>
    <td><input name="Arch[12]" type="checkbox" value="Colonial">Colonial</td>
    <td><input name="Arch[13]" type="checkbox" value="Spanish">Spanish</td>
    <td> <input name="Arch[14]" type="checkbox" value="Tudor">Tudor</td>
  </tr>

Keep in mind i am semi new to php and a colete dumbie. You will have to hold my hand lol

Link to comment
Share on other sites

<?php

  if (isset($_POST['submit'])) {
    foreach($_POST['Arch'] as $v) {
      if (mysql_query("INSERT INTO tbl (Arch) VALUES ('$v');")) {
        echo "$v added<br />";
      }
    }
  }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.