hello everyone, i need some help. i am a beginner in web programming. i am trying to make a php code which i will use to input the mark of the student. first three field will be those input mark. in next field i would like to show the ceil(sum) of first three field’s input. and in next one i would like to show the grade of the corresponding total mark. (0-39 = F, 40-44= E, 45-49= D, 50-54 = C-, 55-59 = C, 60-64 = C+, 65-69 = B-, 70–74 = B, 75-79 = B+, 80- 84 = A-, 85-89 = A, 90-100 = A+).
The problem is i want to show the total and grade before i submitting the form. is there any way to do this? another thing, is there any way to check the input value and prevent user to put wrong value (1st term=0-20, 2nd term=0-20, Final=60). please i need detail help.
Thanks
The problem is i want to show the total and grade before i submitting the form. is there any way to do this? another thing, is there any way to check the input value and prevent user to put wrong value (1st term=0-20, 2nd term=0-20, Final=60). please i need detail help.
Thanks
PHP:
<form method="post" action="input_mark.php">
<table width="90%" align="center" border="0">
<?php
include "db.php";
$code=$_GET['code'];
$program=$_GET['program'];
$sub=mysql_query("select title from subject where code='$code'");
$sub_t=mysql_fetch_array($sub);
echo"<br /><h4 align=center>Cource Title: $sub_t[title]</h4><br />";
echo "<input name=code type=hidden value=$code>";
$reg=mysql_query("select id from registration where code='$code' and program='$program' and edit=0");
$reg_id=mysql_fetch_array($reg);
if(!$reg_id){
echo "<tr>
<td colspan=7 align=center><font color=red><br /><b>No any Student has been registred for this subject</b></font></td>
</tr>";
}
else{
echo"<tr>
<td ><strong>ID</strong></td>
<td ><strong>Name</strong></td>
<td ><strong>1st Term (0 - 20)</strong></td>
<td ><strong>2nd Term (0 - 20)</strong></td>
<td ><strong>Final Term (0 - 60)</strong></td>
<td ><strong>Total</strong></td>
<td ><strong>Grade</strong></td>
</tr>";
$sql=mysql_query("select re.id, name, season from registration re, student st where re.id=st.id and code='$code' and edit=0");
while($db=mysql_fetch_array($sql)){
echo"<tr>
<td><input name=id[$db[id]] type=hidden value=$db[id]>$db[id]</td>
<td>$db[name]</td>
<td><input name=1stterm[$db[id]] type=text ></td>
<td ><input name=2ndterm[$db[id]] type=text ></td>
<td ><input name=final[$db[id]] type=text ></td>
<td ><input name=total[$db[id]] type=readonly value=""></td>
<td ><input name=grade[$db[id]] type=readonly value=""></td>
<input name=season type=hidden value=$db[season]>
</tr>";
}
echo"<tr>
<td colspan=7 align=center><input type=submit name=Submit value=Submit></td>
</tr>";
}
?>
</table>
</form>