Hi,
Ive been at this all weekend and can't figure it out.... I need to take it name and 3 results via a form and store this in a mysql database - done. Then I need to print on screen via php who got the highest score. The highest score is got by adding the 3 results together and the biggest sum of the 3 is the highest. I dont know how to do this.... code below is an idea of what i was trying to do but it wont work.. any help appreciated :)
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'exam';
mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database');
mysql_select_db("$dbname") or die ("unable to conect to database");
$table = 'details';
$fname = $_POST['fname'];
$surname = $_POST['surname'];
$student_number = $_POST['student_number'];
$exam = $_POST['exam'];
$project = $_POST['project'];
$participation = $_POST['participation'];
$Totalmark = $exam + $project + $participation;
$sqlquery = "INSERT INTO details VALUES ('$fname', '$surname', '$student_number', '$exam', '$project', '$participation', '$Totalmark')";
$results = mysql_query($sqlquery);
?>
<?php // code to get final grades
//$sqlquery2 = "SELECT max($Totalmark) $fname, $surname FROM details";
//$results2 = mysql_query($sqlquery2);
?>
<!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=iso-8859-1" />
<title>Exam Results</title>
</head>
<body>
<center><h1> Exam Results </h1></center>
<?php
while($row = mysql_fetch_array($results2))
{
?>
<?php
echo $Totalmark ['Totalmark'] ///plus name etc
?>
<?php
}
?>
</body>
</html>