|
i was going to make this all complex.. but if this is a beginner project, then just do it like this.. all you need is one table:
tablename: racers
fields:
name ( varchar(30) )
score ( int )
ok, now you php scripts are going to be what calculate and add to the scores . . . you will need a form for the 12 racer race, and the 2 racer race.
<html>
<body>
<form method=post action=php_self>
1st place <input type=text name=racer_1><br>
2nd place <input type=text name=racer_2><br>
3rd place <input type=text name=racer_3><br>
4th place <input type=text name=racer_4> <input type=submit name=submit value=Submit>
</form>
<!--ok .. now the php script would look something like this: -->
<?
// i would place this php script before any html on the page
// if the form was submitted, execute this code
if($submit){
// hoepfully you already have a connect script
include("connect.php");
for($i=0;$i<4;$i++){
// define scores for each place
if($i==0){
$add=10;
} elseif ($i==1){
$finished=6;
} elsif ($i==2){
$finished==4;
} elseif ($i==3) {
$finished=1;
}
// check to see if the racer exists in the table racers
$result=mysql_query("select * from racers where name='racer_$place'");
// if the racer exists, get current score and add to it
if($result){
$current_score=mysql_result($result,0,"score");
$score=$current_score + $finished;
// then update the table with the new score
$result=mysql_query("update racers set score='$score' where name='$racer_$place'");
// else, if the racer doesn't exist.. insert a new record with the score
} else {
$result=mysql_query("insert into racers set name='racer_$place',score='$finished'");
}
}
}
?>
</body>
</html>
ok, now this should add the correct info to your table.. now to display it .. i'll write this in the next post.
Last edited by sde; 06-11-2002 at 10:00 PM.
|