Forum Moderators: coopster
Form:
<input name="MyID" type="hidden" id="MyID" value="<? echo $sessionVar?>" />
<input name="MyCheckbox[]" type="checkbox" id="MyCheckbox[]" value="1" />
<input name="MyScore[]" type="text" id="MyScore[]"/>
<input name="MyCheckbox[]" type="checkbox" id="MyCheckbox[]" value="1" />
<input name="MyScore[]" type="text" id="MyScore[]"/>
Query:
for ($i=0; $i < 3; $i++) {
$querySQL = sprintf("INSERT into tblMytable (MyID=%s, MyScore=%s,MyCheckbox=%s",
stripString($_POST['MyID'], "int"),
stripString($_POST['MyScore'][$i], "int"),
stripString($_POST['MyCheckbox'][$i], "int"));
run query etc.. }
When i run this i get a non-descript sql error. I;m just wondering if there is a better way to do this? And also, the checkbox values never seem to appear. (I've checked the data with a print_r($_POST).)
Help?
Can you check what you get by printing $querySQL and $querySQL2?
$MyID = stripString($_POST['MyID']
$MyScore = stripString($_POST['MyScore']);
$MyCheckbox = stripString($_POST['MyCheckbox'];
$querySQL = "INSERT into tblMytable (MyID, MyScore,MyCheckbox)
". $MyID) .",
". $MyScore[0]) .",
". $MyCheckbox[0]) ."";
echo $querySQL;
$querySQL2 = "INSERT into tblMytable (MyID, MyScore,MyCheckbox)
". $MyID) .",
". $MyScore[1]) .",
". $MyCheckbox[1]) ."";
echo $querySQL2;
Habtom