Problem with selection for "teacher" variable
Posted: Wed Nov 13, 2002 2:57 am
The script is intended to add a staff member to the location they are employed at.
The problem I am having is that:
The problem I am having is that:
works for the first three locations that I submitted, but the most recent locations that I've added seems to refuse to show any of the teacher/staff member names on database in the selection bar. I've looked through the code the past couple of days and still miffed.<select name = "teacher">
<?
for ($y = 0; $y < sizeof($t); $y++)
{
?> <option value = "<?= $t[$y][0] ?>"> <?= $t[$y][2] . ", " . $t[$y][1] ?>
Code: Select all
<?
require("../require.inc");
SQLinit();
$result = Authorize($Session, 0); // admin
$result2 = Authorize($Session, 1); // ordinary guy
OpenPage($Session);
if ($result2 == 0)
{
echo "You must be logged in to submit anything";
ClosePage();
exit;
}
if ($Location == "")
{
if ($submit == "")
{
LocationList();
}
}
elseif ($submit == "")
{
SubmitForm($Location);
}
if ($submit == "Submit")
{
DoQuery("insert into LocStaff (StaffId, LocationId) values ("$teacher", "$Id")", 0);
$s = DoQuery("select count(*) from LocStaff where LocationId = $Id", 1);
$ins = $sї0]ї0];
DoQuery("update LocStaff set Priority = $ins where
StaffId = "$teacher" AND LocationId = "$Id"", 0);
$r = DoQuery("Select *, Staff.LastName, Staff.FirstName from LocStaff
left join Staff on Staff.Id = LocStaff.StaffId where LocationId = $Id order by Priority", 1);
?>
<p class = "normal">
Success!
Now feel free to
<a href = "/admin/index.php"> go back </a> to the main admin page.
</p>
<p class = "normal"> Here are the teachers in this location: <ol>
<?
for ($x = 0; $x < sizeof($r); $x++)
{
echo "<li> " . $rї$x]ї5] . ", " . $rї$x]ї6] . " Priority #" . $rї$x]ї3];
}
}
ClosePage();
function SubmitForm($l)
{
$s = DoQuery("select * from Locations where Id = $l", 1);
$r = DoQuery("select StaffId, Staff.LastName, Staff.FirstName from LocStaff
left join Staff on Staff.Id = LocStaff.StaffId where LocationId = $l order by Priority", 1);
$w = DoQuery("select Staff.Id, LocStaff.LocationId from Staff
left join LocStaff on LocStaff.StaffId = Staff.Id where LocStaff.LocationId = $l", 1);
$esj = "";
for ($ssf = 0; $ssf < sizeof($w); $ssf++) {
if ($ssf != 0) $esj = $esj . ",";
$esj = $esj . " ". $wї$ssf]ї0];
$t = DoQuery("select Staff.Id, Staff.FirstName, Staff.LastName from Staff where Id not in ($esj)", 1);
}
?>
<BR>
<span class = "title"> Add Staff to Location #<?= $sї0]ї0] ?> (<?= $sї0]ї1] ?>) </span>
<p class = "normal"> Current Staff </p>
<ul>
<?
for ($x = 0; $x < sizeof($r); $x++)
{
?><li> <?= $rї$x]ї0] ?>: <?= $rї$x]ї1] ?>, <?= $rї$x]ї2] ?> <?
}
if (sizeof($r) == 0)
{
?><li> No Staff Listed at this time. <?
}
?>
</ul>
<form name = "SubmitPicture" action = "/admin/locationaddstaff.php" method = "POST">
<table cellpadding = 0 cellspacing = 2 border = 0>
<tr><td class = "normal">Teacher</td><td>
<?
if (sizeof($t) == 50)
{
echo "All of your staff are employed here already";
}
else {
?>
<select name = "teacher">
<?
for ($y = 0; $y < sizeof($t); $y++)
{
?> <option value = "<?= $tї$y]ї0] ?>"> <?= $tї$y]ї2] . ", " . $tї$y]ї1] ?> <?
}
?>
</select>
<? } ?>
<input type = "hidden" name = "Id" value = "<?= $l ?>">
</td></tr>
<tr>
<td><input type = "reset"></td>
<td><input type = "submit" name = "submit" value = "Submit"></td>
</tr>
</table>
<p><a href = "/admin/index.php"> Forget this </a> and go back to the admin page.</p>
</form>
<?
}
Function LocationList()
{
$r = DoQuery("Select * from Locations", 1);
?> <p class = "title"> Add Staff to Location </p>
<ul>
<?
for ($x = 0; $x < sizeof($r); $x++)
{ ?>
<li> <a href = "/admin/locationaddstaff.php?Location=<?= $rї$x]ї0] ?>"> <?= $rї$x]ї1] ?> </a>
<? }
?></ul><?
}
?>