I have a table of checkboxes and values, if the user selects a checkbox, they select the id value in an array called checkedHW for simplicity, this is how the code looks:
$ids = implode(',',arrayofids);
$sql = "insert into table(id, type) values($ids,type);
$db->query($sql);
ping for testing:
"insert into table('id1,id2','type')
I thought that if I go through this request, I could hypothetically do this:
"insert into table('id1','type');"
"insert into table('id2','type');"
but I'm not quite sure how to do this, any help would be great :)
I really solved this using:
for($i=0;$i<count(arrayofids); $i++){
$sql = "insert into table(id,type) values(array[$i], 'type'";
$db->query($sql);}
I hope this helps someone and thank you guys for your help!
source
share