Hi there,

I was wondering if someone could tell me how to store multiple checkbox values into a MySQL table?

I know how to work it with Python on its own but I need to store into a database.

Any ideas?

Recommended Answers

All 6 Replies

It depends how you want to store them in your database - all in one column or in multiple columns

I want it to store each checked box into a different field

In which case each checkbox must have a different name and the posted values from each can then be inserted into or updated in the database into the relevant fields.

I had tried that with no avail.

I tried using a for statement as well using mykey but it didn't work either.

Please post your form and php / query code as we cannot help without seeing it. Also if you get any errors, what are they?

This is what I currently have:

boxes = { "des" : "Website Design",\
          "svr" : "Web Server Administration",\
          "com" : "Electronic Commerce",\
          "mkt" : "Web Marketing/Advertising",\
          "edu" : "Web-Related Education" }

store = form['boxes'].value
comments = boxes[store]

This is currently returning an error: <type 'exceptions.KeyError'>: 'boxes'
args = ('boxes',)
message = 'boxes'

I want the user to be able to click on the checkboxes and for the checked boxes to be stored into a database field.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.