I have tried to get this to work with no avail:
I tried these two functions:
function get_teacher_name($idteacher)
{
$query = "SELECT * FROM teachers WHERE teacher_id = $idteacher";
$results = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($results))
{
//echo "<td>Name:{$t['teacher_name']}</td>\n";
if ($idteacher == $row['teacher_id'])
{
echo "<strong>{$row['teacher_name']}</strong>";
return $row['$teacher_name'];
}
}
}
function get_teacher_id($teacherid)
{
$query = "SELECT * FROM teachers WHERE teacher_id = $teacherid";
$results = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($results))
{
//echo "<td>Name:{$t['teacher_name']}</td>\n";
if ($teacherid == $row['teacher_id'])
{
return $row['$teacher_id'];
}
}
}
and then tried to retrieve them and I know that is working because it is returning the name from the teacher and their associated teacher ID
this code has been updated but still is not working
echo "<tr><td>Current Teacher:</td><td>";
$oldteacher = get_teacher_name($row['teacher_id']);
$oldteacher_id = get_teacher_id($row['teacher_id']);
echo "</td></tr><tr>
<td> New Teacher:</td>
<td>";
$newteacher_query = 'SELECT teacher_id, teacher_name FROM teachers ORDER BY teacher_name';
$s = mysql_query($newteacher_query) or exit(mysql_error());
echo '<select name="teacherid">';
if ($oldteacherid == $row['teacher_id'])
{
echo '<option value="' . $rows['teacher_id']. '" selected="selected">' . $rows['teacher_id'] . ' Teacher Id = <strong></option>';
}
else
{
while ($rows = mysql_fetch_assoc($s))
{
echo '<option value="' . $rows['teacher_id'] . '">' . $rows['teacher_name'] . ' (Teacher Id = <strong>' .$rows['teacher_id']. ') - Not working</strong></option>';
echo $oldteacherid;
}
}
echo '</select>';
you can view that by going here:
http://www.sportsrant.com/school/edit_student.php?id=17
you will notice that in the else statement, I placed not working in the drop down, showing that I am not properly selecting the teacher that is already in the database and assigned to that student
any help would be appreciated!
feel free to update the data, this is only a beta
THANKS IN ADVANCE!