I’m trying to enter a value in a specific records , I have a code where the user select a course from a drop down list then add students from a table through check-box to the course , the thing is when I’m trying to insert the course ID into the student table i cant choose the students that the user choose !!
here is my code :
<?php
include("S.php");
$connectdb = mysql_connect('localhost','root','sara') or die ("Not Connect");
if (!$connectdb)
{
die('Could not connect :'. mysql_errno());
}
$selestdb = mysql_select_db('iexa', $connectdb) or die ("not selected database");
$count = count($foo);
for ($i = 0; $i <= $count; $i++){
$Student = $foo[$i];
$res = mysql_query("SELECT St_ID FROM student WHERE St_ID='$Student'");
while($row = mysql_fetch_array($res))
{
$sql ="INSERT INTO student (ID) VALUES ('$_POST[$row['courseID'] . "]')";
}
}
if (!mysql_query($sql,$connectdb))
{
die ('Error :'.mysql_error());
}
echo "The Students are add to the course <br />";
mysql_close($connectdb) ;
?>
where $foo is the array that contain the students ID that were chosen to add to the course
this is the error that i got :
Parse error: syntax error, unexpected ‘[‘, expecting ‘]’ in C:\AppServ\www\test\S2.php on line 20
The error is here:
It should be: