View previous topic :: View next topic |
Author |
Message |
blinkydragon -
Joined: 29 Apr 2004 Posts: 10
|
Posted: Sat May 01, 2004 3:53 pm Post subject: stuck on some coding |
|
|
hey!
this is my first solo php project and i thought i may as well make something useful to use for my classes ^_^
i want to make a php script that will tally the scores of 6 assignments
from each student then average them (one student at a time),
ive got the html form submitting to the php doc with the averaging working so far.
the tricky part is to show the top 3 students as it goes along.
(shows the currently entered students score then shows the top 3 so far)
??? |
|
Back to top |
|
 |
blinkydragon -
Joined: 29 Apr 2004 Posts: 10
|
Posted: Sat May 01, 2004 5:26 pm Post subject: |
|
|
ill try to make it clearer, because even im confused lol.
i want to enter 6 numbers and it gives an average.
Do this 6 times.
Get the list of the top 3 averages as it goes along (displays the latest average and shows the top 3 so far)
i want to be able to input my assignments (6 per class) and get the average for that class, for my 6 classes (each class comprising of 6 assignments on their own form) and end up with the best 3 classes on each page after data entry of the assignments and the average for the class. |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sat May 01, 2004 11:36 pm Post subject: |
|
|
What do you have so far? _________________ Bienvenidos! |
|
Back to top |
 |
 |
blinkydragon -
Joined: 29 Apr 2004 Posts: 10
|
Posted: Sun May 02, 2004 5:33 am Post subject: |
|
|
This is what i did:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h1>classes</h1>
<form action="ass.php" method="post">
<p>Class Name
<input name="diversname" type="test" id="diversname">
</p>
<p>Score 1
<input name="score1" type="test" id="score1"></p>
<p>Score 2
<input name="score2" type="text" id="score2">
</p>
<p>Score 3
<input name="score3" type="text" id="score3">
</p>
<p>Score 4
<input name="score4" type="text" id="score4">
</p>
<p>Score 5
<input name="score5" type="text" id="score5">
</p>
<p>Score 6
<input name="score6" type="text" id="score6">
</p>
<p>Difficulty
<input name="difficulty" type="text" id="difficulty">
</p>
<p><input type="submit"></p>
</form>
</body>
</html>
<?php
echo "Class Name: ";
echo $_POST["classname"];
echo "<br>";
echo "Judge One: ";
echo $_POST["score1"];
echo "<br>";
echo "Judge Two: ";
echo $_POST["score2"];
echo "<br>";
echo "Judge Three: ";
echo $_POST["score3"];
echo "<br>";
echo "Judge Four: ";
echo $_POST["score4"];
echo "<br>";
echo "Judge Five: ";
echo $_POST["score5"];
echo "<br>";
echo "Judge Six: ";
echo $_POST["score6"];
echo "<br>";
$totalclass1 = ($_POST["score1"] + $_POST["score2"] + $_POST["score3"] + $_POST["score4"] + $_POST["score5"] + $_POST["score6"]) / 6 + $_POST["difficulty"];
echo 'Total Score: '.number_format($totalclass1,2).'<br />';
echo "<input type=\"hidden\" name=\"diver1\" value=\"$classdiver1\">\n";
$diversname = $_POST["classname"];
$score1 = $_POST["score1"];
$score2 = $_POST["score2"];
$score3 = $_POST["score3"];
$score4 = $_POST["score4"];
$score5 = $_POST["score5"];
$score6 = $_POST["score6"];
echo "<br>";
if ($score1 > $score2) {
echo "class ".$classname." is in first place!";
exit;
}
?> |
|
Back to top |
|
 |
blinkydragon -
Joined: 29 Apr 2004 Posts: 10
|
Posted: Sun May 02, 2004 5:38 am Post subject: |
|
|
this is half finished code that i got help with..i dont understand whats going on though!
<?php
error_reporting(E_ALL);
if (isset($_POST['classid'])) {
$total = ($_POST["score1"] + $_POST["score2"] + $_POST["score3"] +
$_POST["score4"] + $_POST["score5"] + $_POST["score6"]) / 6 +
$_POST["difficulty"];
$total = $total." {$_POST['classname']}";
$classid = $classid + 1;
}
else $classid = 1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"
/>
<title>Class Score Script</title>
</head>
<body>
<h1>Class Scores</h1>
<form action="<?php echo $_SERVER['REQUEST_URI'];
if ($classid == 2) echo "?$classid=$total";
if ($classid > 2) echo "&$classid=$total";
?>" method="post">
<label for="classname">Class Name</label>
<input name="classname" type="test" id="classname" /><br />
<label for="score1">Score 1</label>
<input name="score1" type="test" id="score1" /><br />
<label for="score2">Score 2 </label>
<input name="score2" type="text" id="score2" /><br />
<label for="score3">Score 3 </label>
<input name="score3" type="text" id="score3" /><br />
<label for="score4">Score 4 </label>
<input name="score4" type="text" id="score4" /><br />
<label for="score5">Score 5 </label>
<input name="score5" type="text" id="score5" /><br />
<label for="score6">Score 6 </label>
<input name="score6" type="text" id="score6" /><br />
<label for="difficulty">Difficulty</label>
<input name="difficulty" type="text" id="difficulty" /><br /><br />
<input name="classid" type="hidden" id="classid" value="<?=$classid?>"
/>
<input type="submit" />
</form>
</body>
</html>
<?php
if (isset($_POST['classid'])) {
echo "Class Name: {$_POST["classname"]}<br />";
echo "Assignment 1: {$_POST["score1"]}<br />";
echo "Assignment 2: {$_POST["score2"]}<br />";
echo "Assignment 3: {$_POST["score3"]}<br />";
echo "Assignment 4: {$_POST["score4"]}<br />";
echo "Assignment 5: {$_POST["score5"]}<br />";
echo "Assignment 6: {$_POST["score6"]}<br />";
echo 'Score: '.number_format($total,2).'<br />';
sort($_GET);
while (list($key, $val) = each($_GET)) {
echo "$key = ".$val."<br />\r\n";
}
}
?> |
|
Back to top |
|
 |
|