|
Posted by LS on 06/17/05 07:18
1. When I select an assignment, the class roster disappears. I don't want it to show up until I select an assignment.
2. I want to be able to enter grades and submit all with only one submit button.
This is my code. File is loaded at http://lynnesmith.net/teacher/entergrades.php
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<HTML>
<HEAD>
<TITLE>Gradebook</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="../stylesheets/gradebook.css">
</HEAD>
<BODY>
<?PHP
include("connect.php");
$CONNECTION = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS) or die ('I
cannot connect to the database because: ' . mysql_error());
mysql_select_db($DB_NAME) or die("Couldn't select database.");
?>
<DIV ID="header">
Enter Grades
</DIV>
<DIV ID="instructions">
<FORM ACTION="entergrades.php" METHOD="post">
<SELECT NAME='classid' SIZE='1'>
<OPTION VALUE='0' SELECTED>--- Select Class ---</OPTION>
<?PHP
$SQL = "SELECT * FROM $DB_TABLE ORDER BY classname";
$RESULT = mysql_query($SQL, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
while ($ROW = mysql_fetch_array($RESULT))
{
$CLASSID = $ROW["classid"];
$CNAME = $ROW["classname"];
echo "<OPTION VALUE='$CLASSID'>$CNAME</OPTION>";
}
?>
</SELECT>
<INPUT TYPE='submit' NAME='checkclass' VALUE="Submit">
</FORM>
<?PHP
if(isset($_POST['checkclass']))
{
$CID = $_POST['classid'];
echo "<FORM ACTION='entergrades.php' METHOD='post'>";
echo "<SELECT NAME='assignid' SIZE='1'>";
echo "<OPTION VALUE='0' SELECTED>--- Select Assignment ---</OPTION>";
$SQL = "SELECT * FROM $DB_TABLE1 WHERE classid = '$CID' ORDER BY name";
$RESULT = mysql_query($SQL, $CONNECTION) OR die ('Query failed: ' .
mysql_error());
$NUM = mysql_num_rows($RESULT);
if ($NUM > 0)
{
while ($ROW = mysql_fetch_array($RESULT))
{
$AID = $ROW["record"];
$ANAME = $ROW["name"];
$VALUE = $ROW["value"];
echo "<OPTION VALUE='$AID'>$ANAME ($VALUE)</OPTION>";
}}
echo "</SELECT>";
echo"<INPUT TYPE='submit' NAME='checkassign' VALUE='Submit'>";
echo "</FORM>";
}
if (isset($_POST['checkassign']))
{
$AID = $_POST['assignid'];
}
?>
</DIV>
<DIV ID="content">
<?PHP
$SQL2 = "SELECT * FROM $DB_TABLE2 WHERE classid = '$CID' ORDER BY
lastname, firstname";
$RESULT2 = mysql_query($SQL2, $CONNECTION) OR die ("Query failed.");
$NUM2 = mysql_num_rows($RESULT2);
if ($NUM2 > 0)
{
echo "<TABLE CELLSPACING='2' CELLPADDING='2' BORDER='1'>";
echo "<TR><TH COLSPAN='4'>$CNAME</TH></TR>";
echo "<TR><TH>ID#</TH><TH>Student</TH><TH>Grade</TH><TH></TH></TR>";
echo "<FORM ACTION='entergrades.php' METHOD='post'>";
while ($ROW = mysql_fetch_array($RESULT2))
{
$SRECORD = $ROW["record"];
$SID = $ROW["studentid"];
$FNAME = $ROW["firstname"];
$LNAME = $ROW["lastname"];
echo "<TR><TD>$SID</TD><TD>$LNAME, $FNAME</TD><TD><INPUT TYPE=text
NAME='grade' SIZE='3' MAXLENGTH='3'></TD></TR>";
}
echo "</FORM>";
echo "<TR><TD COLSPAN='4' ><INPUT TYPE='submit' NAME='grades' VALUE='Add
Grade'></TD> </TR>";
echo "</TABLE>";
}
?>
<?PHP
if(isset($_POST['grades']))
{
$ANUM = $_POST['anum'];
$GRADE = $_POST['grade'];
$SQL3 = "INSERT INTO $DB_TABLE3 (classid, studentid, assignmentid,
grade) VALUES ('$CID', '$SID', '$AID', '$GRADE')";
}
?>
</DIV>
</BODY>
</HTML>
[Back to original message]
|