zero-perfoliate
zero-perfoliate

Author Topic: Inserting Data into a Database  (Read 181 times)

Offline silvermoondragon

  • PHP Workers
  • **
  • Posts: 7
  • Karma: +0/-0
Inserting Data into a Database
« on: July 23, 2010, 09:31:52 AM »
I am working on a form to insert data into my database and I was hoping to be able to use check-boxes. Right now, I have text boxes that work fine, drop-down boxes that work fine, but with the check-boxes only the last check-box checked is entered into the database rather than all the selected boxes.

I am hoping to find a way to get it to work as it would be easier to enter data this way, selecting the applicable check boxes, than having to type out a big long list of things into a text box.

The code I am using for the form is:
Code: [Select]
<input type="checkbox" name="colours" value="Red, " /> <font color="#FF0000">Red</font>
<input type="checkbox" name="colours" value="Orange, "/> <font color="#FF9900">Orange</font>
<input type="checkbox" name="colours" value="Yellow, "/> <font color="#FFFF00">Yellow</font>
<input type="checkbox" name="colours" value="Light Green, "/> <font color="#33FF00">Light Green</font>

Offline Andrei

  • Administrator
  • PHP Workers
  • *****
  • Posts: 11
  • Karma: +0/-0
Re: Inserting Data into a Database
« Reply #1 on: July 25, 2010, 02:30:03 AM »
 You are using the same name for input fields without the brackets. use colours[] for the inputs name.

 

zero-perfoliate