//In this program, Mutago with student_regno of 20094145 has total_score of 10 already existing in the database. So i want to get that
total_score of 10 from database and add it to incoming student_score.
the problem is that the database student_totalscore is not updated and it seems that student_totalscore eg 10
is not selected from database and hence not added to the incoming student_score. Any help please. Is there anyway to solve this problem using object oriented programming. All am trying to do is to keep on updating the database each time studentscore were entered
thanks
<?php
mysql_connect("localhost", "mutago", "mut67RT") or die(mysql_error());
mysql_select_db("student_database") or die(mysql_error());
$student_totalscore='';
$student_regno=$_POST['student_regno'];
$student_score=$_POST['student_score'];
// get student_totalscore from database and add it to incoming student_score
function student_record ()
{
$data = mysql_query("SELECT student_totalscore FROM student_result where student_regno='student_regno'")
or die(mysql_error());
$result = mysql_fetch_array( $data );
// get Mutago totalscore of 10 from database and add it to incoming score(student_score)
$total = $result[student_totalscore] + $_POST['student_score'];
// now update the database
$up = "UPDATE student_result SET student_totalscore='total' WHERE student_regno='student_regno'";
$result=mysql_query($up);
if($result){
echo "congratulations ";
}
else {
echo "you cannot update";
}
mysql_close();
?>


Sign In
Create Account


Back to top









