
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 1.04 KB | hits: 12 | expires: Never
<?php
if(isset($_POST['finalGrade'])){
$STUDENTS = $_POST['students'];
$transScore = $_POST['finalscore'];
foreach($STUDENTS as $s){
foreach($transScore as $ts){
$addfinal = Performance::insertFinal($s, $ts);
}
}
}
?>
<?php if(!is_null($students)):?>
<tr>
<?php foreach ($students as $s):?>
<input type="hidden" name="students[]" value="<?php echo $s['student_id'];?>">
<td style="text-align:left;"><?php echo $s['lname'] . ", ". $s['fname'] . " ". $s['mname'];?></td>
<td><?php echo $score;?></td><input type="hidden" name='finalscore[]' value="<?php echo $score;?>">
<?php else:?>
<td><i>no record yet</i></td>
<?php endif;?></td>
<input type="submit" name="finalGrade" value="add to class record" >
//function
public static function insertFinal($student, $grade){
$query = "INSERT INTO student_class (student_id, score)
VALUES ('{$student}', '{$grade}')";
$sql = mysql_query($query) or die("error");
if(mysql_affected_rows()>0){
return TRUE;
}else{
return FALSE;
}
}