diff options
author | arun <arun@nubati.net> | 2007-02-03 05:29:17 +0000 |
---|---|---|
committer | arun <arun> | 2007-02-03 05:29:17 +0000 |
commit | 4a0d379346ba2663d019b3e2e5ed28d30e0008ba (patch) | |
tree | 5a4fe647604f5031bd2e26ddbf2131d3d25df899 | |
parent | 14e087ec31455a9d1780ffbf6a2cf883d9b6bfc5 (diff) | |
download | e-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.php | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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]); } ?> |