Newbie question here: I have successfully created a form that that displays students (based on a selected lesson/group/date) with the ability to enter scores.
I'm now trying to set the form up so that if data already exists then it is displayed in the form.
Eg: if a member of staff choses group 7AS, lesson 1, 24/09/2010 and another member of staff has entered a score already for one student it shows up in the <select> drop down by using:
<option>" . $scorevalue . "</option>
I had this working at one point but have made a change somewhere and cannot get it working again! can anyone spot an obvious mistake I am making?
The code I am using is as follows:
<input type="hidden" name="tutor" value="<?php echo $_GET["tutor"]; ?>" />
<input type="hidden" name="date" value="<?php echo $_GET["date"]; ?>" />
<input type="hidden" name="lesson" value="<?php echo $_GET["lesson"]; ?>" />
<?php
error_reporting(-1);
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("lakeside", $con);
$result = mysql_query("SELECT students.admin, students.fname, students.surname, students.tutor
FROM students
WHERE tutor='$_GET[tutor]'
ORDER BY students.tutor, students.surname");
echo "<table class='scores'>
<tr>
<th>Admin</th>
<th>Firstname</th>
<th>Surname</th>
<th>Tutor</th>
<th>Score</th>
<th>Code</th>
<th>Comment</th>
</tr>";
while($row = mysql_fetch_array($result))
{
$sqlstatement = "SELECT * FROM scores where admin = '" . $row['admin'] . "' and lesson = '" . $_GET[lesson] . "' and date = '" . $_GET[date] . "' ";
$scorevalue = mysql_query($sqlstatement);
echo " . $score . ";
while($rowvalue = mysql_fetch_array($scorevalue))
{
$score = $rowvalue['score'];
$comment = $rowvalue['comment'];
$code = $rowvalue['code'];
}
echo "<tr>";
echo "<td>" . $row['admin'] . "</td>";
echo "<td>" . $row['fname'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";
echo "<td>" . $row['tutor'] . "</td>";
echo "<td><select name='score" . $row['admin'] . "' value='{$row['score']}' />
<option>" . $scorevalue . "</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>2.5</option>
<option >3</option>
<option>3.5</option>
<option>4</option>
</select>
</td>";