On Saturday 21 April 2001 04:42, [EMAIL PROTECTED] wrote:
> Alrighty. I'm baack! Anyways, I seem to be having stupid little
> problems, al of which are driving me insane. I'll feel really
> stupid when you tell me the problem. A friend told me something about
> "seeding" for random() but I didn't find anything on that.
try this and learn from it :)
<?
if (empty($name)) {
?>
<HTML>
<HEAD>
<TITLE>Horse Race v.1</TITLE>
</HEAD>
<BODY>
Welcome to horse racing v.1. This is a simple PHP game where you can
train, race and win money for your animals. Eventually I'll make it a
whole barn with feeding and horses, and costs, age, breeding. So on.
But for now, this is just a simple game.<br><br>
Enter six names of horses.
<FORM ACTION="<?=$PHP_SELF?>" METHOD="post">
<? for ($i=1;$i<=6;$i++) { // I hate to repeat text ;)
echo "Name$i : <INPUT TYPE=\"text\" NAME=\"name[]\"
size=\"24\"><BR>\n";
?>
<input type="submit" name="submitNms" value="race them!">
</FORM>
<CENTER>Good luck!</CENTER>
</BODY>
</HTML>
<?
} else {
srand((double)microtime()*1000000); // prepare the random sequence.
$randomHorse = round(rand(1,6)); // makes a random horse
$randomStrides = rand(1, 10); // whatever strides are
echo $name[$randomHorse] ." won the race by $randomStrides !
Congratulations."; // the var name is the array from the form..
}
?>
--
php developer / CoreTrek AS | Remembering is for those who have
Sandnes / Rogaland / Norway | forgotten. -- Chinese proverb
web: http://www.moijk.net/ |
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]