Hi everyone. I'm new here. I am developing a project entitled Online Grade Viewer. It goes like this. When a teacher input grade of a student, the equivalent and remarks will be immediately displayed(it's in javascript). My problem here is that I can't view the equivalent and remark of the grade inputted. The number of textbox displayed depends on the number of students enrolled.
Here is my program for that:
<?php
session_start();
if($_SESSION['logged'] != 'true'){
header('location: teacherlogin.php');}
require("conn.php");
$id =$_SESSION['userID'];
$result = mysql_query("SELECT * FROM teacher WHERE userID ='$id'");
$test = mysql_fetch_array($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Entry of Grades</title>
<link href="teacher_style.css" rel="stylesheet" type="text/css" />
<link href="menu.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function getEquivalent()
{
var grade = document.myform.grade.value;
var reitems = '^([1-9])([0-9]{0,2})$';
if(!grade.match(reitems))
{
alert('Input Grades Please!');
}
else
{
var grade = document.myform.grade.value;
if (grade>=98 && grade<=100)
{
document.getElementById('equivalent').value = "1.00"
}
else if (grade>=96 && grade<=97)
{
document.getElementById('equivalent').value = "1.25"
}
else if (grade>=93 && grade<=95)
{
document.getElementById('equivalent').value = "1.50"
}
else if (grade>=90 && grade<=92)
{
document.getElementById('equivalent').value = "1.75"
}
else if (grade>=87 && grade<=89)
{
document.getElementById('equivalent').value = "2.00"
}
else if (grade>=84 && grade<=86)
{
document.getElementById('equivalent').value = "2.25"
}
else if (grade>=81 && grade<=83)
{
document.getElementById('equivalent').value = "2.50"
}
else if (grade>=78 && grade<=80)
{
document.getElementById('equivalent').value = "2.75"
}
else if (grade>=75 && grade<=77)
{
document.getElementById('equivalent').value = "3.00"
}
else if (grade>=60 && grade<=74)
{
document.getElementById('equivalent').value = "5.00"
}
}
if (grade>=75)
{ document.getElementById('remarks').value = "PASSED" }
else
{ document.getElementById('remarks').value = "FAILED" }
}
</script>
</head>
<body>
<div id="container">
<div id="banner">
<div id="main_banner"></div>
</div>
<div id="cssmenu">
<ul>
<li class='has-sub '><a href="#">> Profile</a></li>
<li class='has-sub '><a href="teacher_loads.php">> Subject Loads</a></li>
<li class='has-sub '><a href="teacher_addgrades.php">> Add Grades</a></li>
<li class='has-sub '><a href="teacher_post_announcement.php">> Post Announcement</a></li>
<li class='has-sub '><a href="teacher_changepass.php">> Change Password</a></li>
<li class='has-sub '><a href="logout.php">> Log-out</a></li>
</ul>
</div>
<div id="content">
<div id="main_content">
<form method="post">
<table>
<td>Subject:</td>
<td>
<select name="subjectID" style="width: 150px;">
<option>---Select Subject---</option>
<?php
//include "conn.php";
$id=$_SESSION['userID'];
echo "<br />";
//declare string
$result=mysql_query("SELECT teachersubject.userID,teachersubject.subjectID,subject.description FROM gradeviewer.subject INNER JOIN gradeviewer.teachersubject ON (subject.subjectID = teachersubject.subjectID) WHERE (teachersubject.userID)='".$id."'");
while($row=mysql_fetch_array($result))
{
echo"<option value = '".$row['subjectID']."'>".$row['description']."</option>";
}
?>
</select>
</td>
<tr>
<td>Semester:</td>
<td>
<select name="semesterID" style="width: 150px;">
<option>---Select Semester---</option>
<?php
//declare string
$result=mysql_query("SELECT * FROM semester");
while($row1=mysql_fetch_array($result))
{
echo"<option value = '".$row1['semesterID']."'>".$row1['semesterName']."</option>";
}
?>
</select>
</td>
</tr>
</tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td><input type="submit" value="Search" name="search" class="btn" /></td>
</tr>
</table>
</form>
<form id="myform" method="post" action="teacher_update_grade.php">
<table id="demoTable" style="border: 1px solid rgb(204, 204, 204); table-layout: fixed; " cellspacing="0" width="400" bgcolor="#FFFFFF">
<thead >
<tr>
<th sort="beds" align="center" style="width: 98px;"><span class="style7">ID Number</span></th>
<th sort="beds" align="center" style="width: 150px;"><span class="style7">Name</span></th>
<th sort="beds" align="center" style="width: 90px;"><span class="style7">Subject Code</span></th>
<th sort="beds" align="center" style="width: 80px;"><span class="style7">Average</span></th>
<th sort="beds" align="center" style="width: 80px;"><span class="style7">Equivalent</span></th>
<th sort="beds" align="center" style="width: 80px;"><span class="style7">Remarks</span></th>
</tr>
</thead>
<tbody></tbody>
<?php
include('conn.php');
if(isset($_POST['search']))
{
$subjectID=$_POST['subjectID'];
$semesterID=$_POST['semesterID'];
$query = mysql_query("SELECT * FROM result WHERE subjectID='$subjectID' AND semesterID='$semesterID' AND status=0");
$i=0;
while($row = mysql_fetch_array($query))
{
$id = $row['resultID'];
echo "<tr align='center'>";
$query1=mysql_query("SELECT student.studentName,result.userID FROM result LEFT JOIN student ON result.userID=student.userID WHERE resultID='$id'");
while($row1 = mysql_fetch_array($query1))
{
echo"<td><font color='black'>". $row1['userID']. "</font></td>";
echo"<td><font color='black'>". $row1['studentName']. "</font></td>";
}
$query2=mysql_query("SELECT subject.subjectCode FROM result LEFT JOIN subject ON result.subjectID=subject.subjectID WHERE resultID='$id'");
while($row2 = mysql_fetch_array($query2))
{
echo"<td><font color='black'>". $row2['subjectCode']. "</font></td>";
}
//echo "<td><font color='black'>{$row['resultID']}<input type='hidden' name='resultID[$i]' value='{$row['resultID']}' /></font></td>";
echo"<td><input type='text' id='grade' name='grade[$i]' style='width: 35px;' value='" .$row['grade']. "' onchange='getEquivalent()'/></td>";
echo"<td><input type='text' id='equivalent' name='equivalent[$i]' style='width: 35px;' value='" .$row['equivalent']. "' readonly='true'/></td>";
echo"<td><input type='text' id='remarks' name='remarks[$i]' style='width: 35px;' value='" .$row['remarks']. "' readonly='true'/></td>";
++$i;
}
echo "</tr>";
}
?><br />
</tbody></table>
<br />
<td colspan=7><input type="submit" value="SAVE GRADES" name="btnupdate" class="btn" /></td></form>
</div></div>
<div id="footer">
<div id="main_footer"></div>
</div></div>
</body>
</html>
I hope you can help me with this.
Displaying equivalent and remarks through incremented textbo
Moderator: General Moderators
-
shijhourhyou
- Forum Newbie
- Posts: 1
- Joined: Wed Jan 23, 2013 6:51 am
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Displaying equivalent and remarks through incremented te
welcome to the forum 
Something that will help you get answers much quicker: use tags to wrap you code, it makes it much easier to read
the php code button wraps code in php tags; you can also substitute the php in those tags for the word html, css and javascript to get the applicable tags for your code.
Do you want to use PHP to display these values?shijhourhyou wrote:My problem here is that I can't view the equivalent and remark of the grade inputted.
Something that will help you get answers much quicker: use tags to wrap you code, it makes it much easier to read
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering