I’ve search here for an answer to this error & I’ve tried the tips but it seems that every time some work something else appear ,
what I’m trying to do here is to show a list of the student in the database with a check-box for each one , if the user check the check-box the student should be add to the course that he already choose in the drop down list above , here is the code :
<?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");
$qu = mysql_query("SELECT ID,Name FROM Course ORDER BY ID asc") or die ("mysqlerror");
$result = mysql_query ($qu);
echo "<select name=" .$course. " value=''>Course</option>";
echo "<option value=0>Course ID</option>";
$curvalue=2;
while ($row = mysql_fetch_assoc($qu)){
echo '<option value="$curvalue">".$row[ID]." ".$row[Name]."</option>';
$curvalue = $curvalue+1;
}
echo "</select>";
$query = mysql_query("SELECT St_ID,First,Last FROM student ORDER BY First asc") or die ("mysql error");
echo " <table width='40%' border='1' cellpadding='5'>
<tr>
<td>Check to add to course</td>
<td>Student ID</td>
<td>Student Name</td>
</tr> ";
while ($row = mysql_fetch_assoc($query)){
echo "
<tr>
<td> <input type="checkbox /" name="foo[] /" value=".$row['St_ID']./"> </td>
<td>".$row['St_ID']./"</td>
<td>".$row['Fisrt']./" ".$row['Last']./"</td>
</tr>
";
}
echo "</table>";
?>
This is because in your second to last echo statement, you have double quotes within your string and you are enclosing the string with double quotes..
I have used single quotes to enclose your strings and used concatenation to attach your variables: