Hi,
As my first project, I am making a 'test' cricket game (I like the deep end!) and have learned lots by doing it this way. However, I need a bit of advice.
I need the $score value in the code below to be cumulative rather than just keep adding the last value and forgetting the previous total.
So, if the score is 5 and the batsmans scores 3 more, the score becomes '8', and then if he scores 3 more, 11, etc...
How do i do this?
<?php
session_start();
if(session_is_registered('myusername')){
}
else{
header( "Location: /php/login.php" );
}
require("header.php");
$opponent = $_GET['u'];
$result = mysql_query("SELECT * FROM user WHERE username='$myusername'")
or die(mysql_error());
$row1 = mysql_fetch_array($result) or die(mysql_error());
$result = mysql_query("SELECT * FROM user WHERE userid= '$opponent'")
or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<table width='600' align='center' border='1'>";
echo "<tr><td>";
echo "Batsmans Skill = ", $row['skill'];
echo "<br><br>Bowlers Skill = ", $row1['skill'], "<br><br>";
$oppskill=$row['skill']/$row1['skill']*50;
$rand=rand(1,100);
if ($rand>=$oppskill) {
echo "OUT";
}
else {
[COLOR="Red"]$runs=0+rand(1,6);
$score=$runs+$runs;
echo "Result Of Bowl = ",$runs;
echo "<br><br>Batsmans Score = ",$score;[/COLOR]}
echo "</td></tr>";
echo "</table>";
}
?>
Any advice would be much appreciated!