Problem with saving the subjects
Posted: Sat Feb 04, 2012 12:18 am
Example code:
Courtesy of Sir samypogs who help me with the checkbox problem...
I have a problem saving that to my database if i checked it...
The Output when i look at my phpmyadmin is like this
My problem is if i enter another student and subjects it would be saved again at the same table which i do not want since i will later show the the record of the student with the according subjects...
Please help me clear myself out i'm confused ???
Code: Select all
<input type="checkbox" name="subject[]" value="ENG" />English
<input type="checkbox" name="subject[]" value="MATH" />Mathematics
<input type="checkbox" name="subject[]" value="SCI" />Science
<input type="checkbox" name="subject[]" value="FIL" />Filipino
<?php
//and the post data would look like
$arrSubjects = $_POST['subject'];//retruns array. Ung mga nakachecked na value na agad ung laman nito
for($i=0;$i<count($arrSubjects);$i++){
mysql_query("INSERT INTO table_name (sub) values ('".$arrSubjects[$i]."')");
}
?>
I have a problem saving that to my database if i checked it...
The Output when i look at my phpmyadmin is like this
Code: Select all
| sub |
MATH
ENG
SCI
FIL
Please help me clear myself out i'm confused ???