March 1, 2009
How to store input from checkboxes into MySQL using PHP?
web2newyork asked:
I want to add categories to a companies database. Based on another tutorial I made three tables:
I want to add categories to a companies database. Based on another tutorial I made three tables:
companies
categories
lookup_category
lookup_category somehow stores the relationship between the other two, but the tutorial’s example code was full of errors and gaps, so I’m stuck.
What’s the most efficient/flexible way to add “a categories dimension” to a collection of records in MySQL? Can anyone give a stripped down working example without BS?
Filed under Programming & Design by administrator

Comments on How to store input from checkboxes into MySQL using PHP?
You can’t check checkboxes in Php, but you can set values in javascript that will be passed to Php:
the form:
function js_check(theForm)
{
if (theForm.elements['checkbox1'].checked)
theForm.elements['phpbox1'].value = 1;
if (theForm.elements['checkbox2'].checked)
theForm.elements['phpbox2'].value = 1;
}
Your receiving Php script reads phpbox#. If set to 1, then box is checked.