PHP: How to get multiple checkbox values from database for same ID?
I am new to php & need little help here. I've following code to INSERT
multiple checkbox values into a table for same ID:
on my form I have:
<input type="checkbox" name="subcat[]" value="Mech">Mech
<input type="checkbox" name="subcat[]" value="Ele">Ele
<input type="checkbox" name="subcat[]" value="Civ">Civ
<input type="checkbox" name="subcat[]" value="Air">Air
<input type="checkbox" name="subcat[]" value="BSL">BSL
I've checked "Mech", "Ele" and "BSL"
and PHP to insert:
$subcat = $_POST['subcat'];
for($i=0; $i<sizeof($subcat);$i++){
$sql1="INSERT INTO mst_scatadd (party_code,scid)
VALUES ('$pcode',$saincat[$i])";
mysql_query($sql1,$con);
}
db looks something like...
sctid | party_code | scid
---------------------------------
1 | 01S001 | Mech
2 | 01S001 | Ele
3 | 01S001 | BSL
4 | 01K207 | Main
Now, how can I retrieve these values from db to my form for the same ID
and make them as checked if I want to edit the checkboxes?
Little help would be appreciated!!
Thanks in adv.
No comments:
Post a Comment