Page 1 of 1

help with checkbox array

Posted: Wed Aug 31, 2005 4:09 am
by carly
Hi I am creating a checkbox array which prins out the name of each skill, such as "ballroom dancing" with three radio buttons for skill level "beginner, intermediate and andvanced"

but i am having trouble inserting the values from the form, so for each checkbox which i checked i need to record that skill and level for that instructor.
I am getting this error when i try to insert:

Notice: Undefined variable: skill_id in f:\inetpub\students\cpe3002\18955673\barry\admin\instructor\AddIns.php on line 247

Notice: Undefined index: skill_level in f:\inetpub\students\cpe3002\18955673\barry\admin\instructor\AddIns.php on line 247

insert into instructor_skill (ins_id, skill_id, skill_level) values (ins_id_seq.currval,,'')
Warning: ociexecute(): OCIStmtExecute: ORA-00936: missing expression in f:\inetpub\students\cpe3002\18955673\barry\admin\instructor\AddIns.php on line 253


Here is my code:

For the checkbox array

Code: Select all

<?
while (OCIFetchInto($stmt, $results, OCI_ASSOC))
{
$skill_id = $results["SKILL_ID"];
?>
<tr>
<td><? echo $results["SKILL_DESC"]; ?></td>
<td><input type="checkbox" name="skill" value="<? echo $results["SKILL_ID"]; ?>"></td>
<td align = "center"><input type = "radio" name = "<? echo $skill_id ?>" value = "advanced" checked /><br />Beginner</td>
   <td align = "center"><input type = "radio" name = "<? echo $skill_id ?>" value = "intermediate" /><br />Intermediate</td>
   <td align = "center"><input type = "radio" name = "<? echo $skill_id ?>" value = "beginner" /><br />Advanced</td>
</tr>

<?
}
?>
For the insert

Code: Select all

for ($counter=0; $counter<sizeof($_POST["skill"]); $counter++)
{

$query = "insert into instructor_skill (ins_id, skill_id, skill_level) values
(ins_id_seq.currval,'".CleanSQL( $_POST["skill_id"][$counter])."','".CleanSQL( $_POST["skill_level"][$counter])."')";


echo $query;
$stmt = OCIParse($conn, $query) or die ('Can not parse query');

OCIExecute($stmt);
OCIFreeStatement($stmt);

}
Any help would be appreciated!

Posted: Wed Aug 31, 2005 7:37 am
by raghavan20
I dont see a form in there.
how do you get the values from the radio buttons???
most notices say that they dont see that the particular variable unset/the POST variable is not set.
dont use super global variables before you knew there is something in it....check for isset()