Jump to content

Olumide

Members
  • Posts

    130
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Olumide

  1. Thanks Boss, I have created the grading table as requested. But please what is now the php code to select the grades to assign to any score entered and post it to the result table. You have shown me the sql codes, but the php to perform the main task sir.
  2. Thanks Boss, I have created the grading table as requested. But please what is now the php code to select the grades to assign to any score entered and post it to the result table. You have shown me the sql codes, but the php to perform the main task sir.
  3. Thanks Boss, I have created the grading table as requested. But please what is now the php code to select the grades to assign to any score entered and post it to the result table. You have shown me the sql codes, but the php to perform the main task sir.
  4. Thanks for your response, but is there a way I can do it without having my low, high marks already in the database but have it in my code?
  5. My question is: how can I do it such that after entering scores for each subject, the grades will be automatically calculated and post to the database.
  6. Am working on a project such that if I enter scores for each subjects, it will post to the database with the grades and comment. My form will only accept value for scores which will determine the grades for each subjects and hence post to the database. Like in Microsoft Excel whereby you have data (integers) and you instruct the excel (lets say you have your value in cell A1, and Cell A2 contains the formula: if(A1>=90,"A",if(A1>=80,"B","F")). I used switch case for the grade in my php code written below. { $marks=array(); $class=$_POST['class']; $studentid=$_POST['studentid']; $mark=$_POST['marks']; $grades=$_POST['grades']; $comments=$_POST['comments']; $stmt = $dbh->prepare("SELECT subjects.SubName,subjects.id FROM subjectlist join subjects on subjects.id=subjectlist.SubjectId WHERE subjectlist.ClassId=:cid order by subjects.SubName"); $stmt->execute(array(':cid' => $class)); $sid1=array(); while($row=$stmt->fetch(PDO::FETCH_ASSOC)) { array_push($sid1,$row['id']); } for($i=0;$i<count($mark);$i++){ $mar=$mark[$i]; $sid=$sid1[$i]; $totalmarks=$marks*10; $sql="INSERT INTO studresult(StudentId,ClassId,SubjectId,marks,grades,comments) VALUES(:studentid,:class,:sid,:marks,:grades,:comments)"; $query = $dbh->prepare($sql); $query->bindParam(':studentid',$studentid,PDO::PARAM_STR); $query->bindParam(':class',$class,PDO::PARAM_STR); $query->bindParam(':sid',$sid,PDO::PARAM_STR); $query->bindParam(':marks',$mar,PDO::PARAM_STR); $query->bindParam(':grades',$grades,PDO::PARAM_STR); $query->bindParam(':comments',$comments,PDO::PARAM_STR); $query->execute(); $lastId = $dbh->lastId(); if($lastId) { $msg="Result successfully added"; } else { $error=" Please try again"; } } } ?> <!-- My Grading starts from here --> <?php switch(true) { case $totalmarks>=90 && $totalmarks<101: $grade = 'A*'; $comment='Congratulation!'; break; case $totalmarks>=85 && $totalmarks<90: $grade = 'A1'; $comment='Distinction'; break; case $totalmarks>=80 && $totalmarks<85: $grade = 'B2'; $comment='Very Good'; break; case $totalmarks>=75 && $totalmarks<80: $grade = 'B3'; $comment='Good'; break; case $totalmarks>=70 && $totalmarks<75: $grade = 'C4'; $comment='Credit'; break; case $totalmarks>=65 && $totalmarks<70: $grade = 'C5'; $comment='Credit'; break; case $totalmarks>=60 && $totalmarks<65: $grade = 'C6'; $comment='Credit'; break; case $totalmarks>=55 && $totalmarks<60: $grade = 'D7'; $comment='Pass'; break; case $totalmarks>=50 && $totalmarks<55: $grade = 'E8'; $comment='Pass'; break; case $totalmarks>=40 && $totalmarks<50: $grade = 'F9'; $comment='Fail'; break; default: $grade = 'F9'; $comment='Ungraded'; break; } ?> <!-- grading stop here -->
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.