summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarun <arun@nubati.net>2007-02-03 05:29:17 +0000
committerarun <arun>2007-02-03 05:29:17 +0000
commit4a0d379346ba2663d019b3e2e5ed28d30e0008ba (patch)
tree5a4fe647604f5031bd2e26ddbf2131d3d25df899
parent14e087ec31455a9d1780ffbf6a2cf883d9b6bfc5 (diff)
downloade-DoKo-4a0d379346ba2663d019b3e2e5ed28d30e0008ba.tar.gz
e-DoKo-4a0d379346ba2663d019b3e2e5ed28d30e0008ba.tar.bz2
e-DoKo-4a0d379346ba2663d019b3e2e5ed28d30e0008ba.zip
when starting a new game, games can't be selected twice anymore and are randomly pre-selected
-rw-r--r--output.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/output.php b/output.php
index ef67ccc..bfebf4a 100644
--- a/output.php
+++ b/output.php
@@ -86,15 +86,26 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
function output_form_for_new_game($names)
{
?>
- <p>Please select four players </p>
+ <p>Please select four players (or use the randomly pre-selected names)</p>
<form action="index.php" method="post">
<?php
foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
{
+ srand((float) microtime() * 10000000);
+ $randkey = array_rand($names);
+ $rand = $names[$randkey];
echo " Name: <select name=\"$player\" size=\"1\" /> \n";
- foreach($names as $name)
- echo " <option>$name</option>\n";
+ foreach($names as $name)
+ {
+ if($name==$rand)
+ {
+ echo " <option selected=\"selected\">$name</option>\n";
+ }
+ else
+ echo " <option>$name</option>\n";
+ }
echo " </select>\n";
+ unset($names[$randkey]);
}
?>