Code: Select all
<html>
<head>
<title>Create 4 10 or 20 random dice</title>
</head>
<body bgcolor="#ffcc99">
<h3>Creating 4 random dice</h3>
<?php
global $numDice;
if(empty($numDice)){
print howManyDice();
} else {
switch($numDice){
case 4:
createRandDice();
createRandDice();
createRandDice();
createRandDice();
break;
case 10:
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
break;
case 20:
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
createRandDice();
break;
default:
createRandDice();
break;
}
}
function createRandDice(){
$rand = rand(1,6);
print <<<HERE
<img src="$randDie.jpg"
alt="$rand"
height ="100"
width ="100">
HERE;
}
function howManyDice(){
$output = <<<HERE
Enter 4, 10, or 20:
<form method ="post">
<input type ="text"
name ="$numDice"
value ="">
<input type ="submit"
value ="Make dice">
</form>
HERE;
return $output;
}
?>
</body>
</html>
Can someone help me? thanks