Hi,
Iam new to PHP I need some help I am trying to insert multiple checkboxes values
<td>
<input name="myvar[]" type="checkbox" value="abc">
abc<br/>
<input name="myvar[]" type="checkbox" value="def">
def<br>
<input name="myvar[]" type="checkbox" value="ghi">
ghi</td>
along with other datas to the database, and I dont know how to do this
I wrote query for inserting other datas to db,(but i dont know how to include the loop value from the checkbox along with this).
$Details=mysql_query("insert into Example values('$ID','$data1','$data2'......) please explain I am new in this field
micahgeorge
0
Newbie Poster
Recommended Answers
Jump to Postassuming you had:
<input type="text" name="person" value="John"/> <input name="sport[]" type="checkbox" value="baseball"> <input name="sport[]" type="checkbox" value="basquetball"> <input name="sport[]" type="checkbox" value="football"> <input name="sport[]" type="checkbox" value="hocket">
then:
foreach($_POST['sport'] as $value) { $sql = sprintf("INSERT INTO `Atletes`(`personId`,`sportName`) VALUES('%s','%s')" ,mysql_real_escape_string($_POST['person']) ,mysql_real_escape_string($value) ); }
All 3 Replies
Reply to this topic
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.