By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

checkboxes in MYSQL table

P: 63
Hi to all.
I have got a form containing of checkboxes along with other items.
I have simply no clue as to
(i) how to make entry for those checkbox data into the mysql table . I mean : what query to put for creating field corresponding to checkboxes. Create table arc(status ---?)
status is the array for checkboxes. what should be the data type and its length.

(II)How to post data from the checkboxes correctly into the database on submit.
Here is the table . plz help


[HTML]<form>
Status (Tick as many as applicable):<br/>
<table width="86%">
<tr>
<td ><input name="status[]" id="st1" type="checkbox" value="accc"></td>
<td width="44%">Air Conditioning Consultants and Contractors</td>
<td ><input name="status[]" id="st2" type="checkbox" value="arbit"></td>
<td width="44%">Arbitrators</td>
</tr>
<tr>
<td width="6%"><input name="status[]" id="st3" type="checkbox" value="bcd"></td>
<td width="44%">Builders,Contractors and Developers</td>
<td width="6%"><input name="status[]" id="st4" type="checkbox" value="bcd"></td>
<td width="44%">Civil Engineers and Contractors</td>
</tr>
<tr>
<td width="6%"><input name="status[]" id="st5" type="checkbox" value="survey"></td>
<td width="44%">Surveyors</td>
<td width="6%"><input name="status[]" id="st6" type="checkbox" value="cse"></td>
<td width="44%">Consulting and Structural Engineers </td>
</tr>
<tr>
<td width="6%" height="39"><input name="status[]" type="checkbox" id="st7" value="eec"></td>
<td width="44%">Electrical Engineers and Contractors</td>
<td width="6%"><input name="status[]" type="checkbox" id="st8" value="ld"></td>
<td width="44%">Landscape Designers </td>
</tr>
<tr>
<td width="6%"><input name="status[]" type="checkbox" id="st9" value="idd"></td>
<td width="44%">Interior Decorators and Designers</td>
<td width="6%"><input name="status[]" type="checkbox" id="st10" value="pcc"></td>
<td width="44%">Pest Control Consultants </td>
</tr>
<tr>
<td width="6%" height="34"><input name="status[]" type="checkbox" id="st11" value="tkc"></td>
<td width="44%">Turnkey Contractors</td>
<td width="6%"><input name="status[]" type="checkbox" id="st12" value="urp"></td>
<td width="44%">Urban and Rural Planners</td>
</tr>
<tr>
<td width="6%"><input name="status[]" type="checkbox" id="st13" value="valp"></td>
<td width="44%">Value and Appraisers - Land and Property</td>
<td width="6%"><input name="status[]" type="checkbox" id="st14" value="wpcc"></td>
<td width="44%">Water Proofing Consultants and Contractors </td>
<tr>
<td width="6%"><input name="status[]" type="checkbox" id="st15" value="pcc"></td>
<td width="44%">Plumbing Consultants and Contractors</td>
<td width="6%"><input name="status[]" type="checkbox" id="st16" value="urp"></td>
<td width="44%">Consultants(Specify)</td>
</tr>
<tr>
<td width="6%"><input name="status[]" type="checkbox" id="st17" value="others"></td>
<td width="44%">Others</td>
<td width="6%"> </td>
</tr>
</table>
<td>&nbsp;</td><br/>
Projects Executed (max.3):
<table width="66%">
<tr>
<td>(i)</td> <td><textarea name="prexec1" cols="65" rows="5"></textarea></td>
</tr>
</tr>
<tr>
<td>(ii)</td> <td width="95%"><textarea name="prexec2" cols="65" rows="5"></textarea></td>
</tr>
<tr>
<tr>
<td>(iii)</td> <td><textarea name="prexec3" cols="65" rows="5"></textarea></td>
</tr>
</table>
<td>&nbsp;</td><br/>
Current Projects :
<table width="66%">
<tr>
<td>(i)</td> <td colspan="5"(ii) ><textarea name="curprj1" cols="65" rows="5"></textarea></td>
</tr>
<tr>
<td>(ii)</td> <td><textarea name="curprj2" cols="65" rows="5"></textarea></td>
</tr>
<tr>
<td>(iii)</td> <td><textarea name="curprj3" cols="65" rows="5"></textarea></td>
</tr>
</table>
<p>&nbsp;</p>
<table>
<tr>
<td width="26%">Award/Honours won:</td> <td width="60%"><input type="text" size="50" name="awards"> </td>
</tr>
</table>
<table>
<tr><td>
I hereby declare that the above information is true to the best
of my knowledge and belief and have no objection to the data
being used for this or any other publication in print or electronic
media by the publishers. please take me as a subscriber for you
"Web News Letter" free of cost .
</td></tr>
</table>
<br>
<table>
<tr>
<td colspan="5">Key Person : </td><td width="35%"><input type="text" size="20" name="key"> </td>
<td colspan="5">Designation: </td><td width="35%"><input type="text" size="20" name="design"> </td>
</tr>
</table>
</form>[/HTML]
Oct 24 '07 #1
Share this Question
Share on Google+
1 Reply


realin
100+
P: 254
that is a long post.. well if you want to submit check boxes value using the name of the checkbox to get its value after submission of the form.

Suppose the checkbox name is chk1 then you can do

[PHP]$set=$_POST['chk1'][/PHP]


if $set will be 0 then that means the checkbox was never set if 1 then it was set :)
Oct 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.