Hello there.!this is a little game with 6 dice pictures, when you reload the page it shows you how many 'kings' and 'soldiers' are in totally in the given random pictures! each time you reload the page the number of kings and soldiers change.. Now my problem is that i want to make it like, the user should write how many 'kings' and 'soldiers' are there and when he press the submit button, a message will show if his answer is correct or not..if its not, it should display the correct number of kings and soldiers that are there! (the 'kings' are the circles in the middle of each pic! if there's no circle in the middle of any pic, that means there are no 'kings' there) i spent lot of hours with this, trying to do it with if else if and with switch cases but the only thing i got, were errors -.- i hope some 1 of you will help me to solve this! HERE ARE 2 PICS OF HOW IT LOOKS LIKE: http://imgur.com/EVP8mMQ,HaMZL6q#0 http://imgur.com/EVP8mMQ,HaMZL6q#1
THIS IS THE CODE OF THE FIRST PAGE:
<?php
function count_soldiers($res)
{
switch($res){
case 1:
return 0;
break;
case 2:
return 2;
break;
case 3:
return 2;
break;
case 4:
return 4;
break;
case 5:
return 4;
break;
case 6:
return 6;
break;
}
}
function count_kings($res)
{
switch($res){
case 1:
return 1;
break;
case 2:
return 0;
break;
case 3:
return 1;
break;
case 4:
return 0;
break;
case 5:
return 1;
break;
case 6:
return 0;
break;
}
}
function total_kings($r1,$r2,$r3,$r4)
{
$totking = count_kings($r1)+count_kings($r2)+count_kings($r3)+count_kings($r4);
return $totking;
}
function total_soldiers($r1,$r2,$r3,$r4)
{
$totsoldier = count_soldiers($r1)+count_soldiers($r2)+count_soldiers($r3)+count_soldiers($r4);
return $totsoldier;
}
?> AND THIS IS THE CODE OF THE SECOND PAGE:
<!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>How many kings are?</title>
</head>
<body bgcolor="#e0e0e0">
<div align="center">
<p><h2>How many kings and soldiers are in totally?
</h2>
</p>
<hr/>
<?php
require_once("funksione.php");
$ran = rand(1, 6);
$ran1 = rand(1, 6);
$ran2 = rand(1, 6);
$ran3 = rand(1, 6);
echo "<br/>";
echo "In totally there are ". total_kings($ran,$ran1,$ran2,$ran3).
" kings and ". total_soldiers($ran,$ran1,$ran2,$ran3). " soldiers.";
echo "<br/>";
print "<img src=images/". $ran .".jpg>";
print "<img src=images/". $ran1 .".jpg>";
print "<img src=images/". $ran2 .".jpg>";
print "<img src=images/". $ran3 .".jpg>";
?>
<p><h2>How many kings and soldiers are in totally?
</h2>
</p>
<form method="post" action="example11-2.php">
Kings:
<input type="text" name="name" />
<form method="post" action="example11-2.php">
Soldiers:
<input type="text" name="name" />
<input type="submit" />
</form>
</div>
</body>
</html>