Jump to content

decypher

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

decypher's Achievements

Member

Member (2/5)

0

Reputation

  1. Got it working...Thanks alot everyone *thumbs up*
  2. It didn't work...I've tried it without all the '$cityA = $_POST['cityA'];' or similar coding but i get the same thing...
  3. Html: <html> <head> <title>Basic multi-dimensional array</title> </head> <body> <h1> Basic 2D Array</h1> <form action= basicmultiarray.php> <table border = 1> <tr> <th>First City</th> <th>Second City</th> <tr> <!-- note each option value is numeric --> <tr> <tD> <select name = "CityA"> <option value = 0>Indianapolis</option> <option value = 1>New York</option> <option value = 2>Tokyo</option> <option value = 3>London</option> </seltect> </td> <td> <select name = "CityB"> <option value = 0>Indianapolis</option> <option value = 1>New York</option> <option value = 2>Tokyo</option> <option value = 3>London</option> </seltect> </td> </tr> <tr> <td colspan = 2> <Input type = "submit" Value= "calculate distance"> </td> </tr> </table> </body> </html> PHP: <html> <head> <title> distance Calculator</title> </head> <body> <method = "POST"> <?php $city = $_POST['array']; $cityA = $_POST['cityA']; $cityB = $_POST['cityB']; $city = array("Indianapolis","New York","Tokyo","London"); $distance = array( array (0, 648, 6476, 4000), array (648, 0, 6760, 3470), array (6476, 6760, 0, 5956), array (4999, 3470, 5956, 0) ); $result =$distance[$cityA][$cityB]; print "<h3>The distance between "; print "$city[$cityA] and $city[$cityB]"; print " is $result miles.</3>"; ?> </body> </html> Problem is that when i do the query as such all I get is...'The distance between and is miles.' not gettin the city names or miles...any suggestions? Many thanks in advanced P.S This problem does keep re-occuring when all coding is right...Any reasons why the data doesn't show when I sumbit the button?
  4. //print out a checkbox on first roll only if ($secondroll == FALSE) { print <<<HERE <input type = "checkbox" name = "$keepit[$i]" value = "$die[$i]"> </td> I have a feeling it has to do something with this and me needing to write a code like : $die[$i] = $_POST['$keepit[$i]']; but I've tried that and it doesn't work
  5. Not sure..Learning out of a book but thats all it gives me :S <?php $cash = $_POST['cash']; $secondroll = $_POST['secondroll']; $payoff = $_POST['payoff']; // Check to see if this is first time here if (empty($cash)) $cash = 100; rolldice(); if ($secondroll == TRUE) { print"<h2>Second Roll</h2>\n"; $secondroll = FALSE; evaluate(); } else { print "<h2>First roll</h2>\n"; $secondroll = TRUE; } // end if printstuff(); function rolldice() { global $die, $secondroll, $keepit; print "<table border = 1><td><tr>"; for ($i = 0; $i < 5; $i++) { if ($keepit[$i] == "") { $die[$i] = rand(1, 6); } else { $die[$i] = $keepit[$i]; } // end if //print out dice images print <<<HERE <td> <img src ="die$die[$i].jpg" height = 50 width = 50<br> HERE; //print out a checkbox on first roll only if ($secondroll == FALSE) { print <<<HERE <input type = "checkbox" name = "$keepit[$i]" value = "$die[$i]"> </td> HERE; } // end if } // end for loop //print out submit button and end of table print <<<HERE </tr></tD> <tr> <td colspan = "5"> <center> <input type = "submit" value = "Roll again"> </center> </td> </tr> </table> HERE; } // end rolldice function evaluate() { global $die, $cash; //set up payoff $payoff = o; //subtract some money for this roll $cash -=2; //count the dice $numvals= array(6); for ($theval = 1; $theval <= 6; $theval++) { for ($dienum = 0; $dienum < 5; $dienum++) { if ($die[$dienum] == $theval) { $numvals[$theval]++; } // end if } // end dienum for loop } // end theval for loop //print out results // for ($i = 1; $i <= 6; $i++){ // print "$i: $numvals[$i]<br>\n"; // } end for loop //count how many pairs, threesm fours, fives $numpairs = 0; $numthrees = 0; $numfours = 0; $numfives = 0; for ($i = 1; $i <=6; $i++) { switch ($numvals[$i]) { case 2: $numpairs++; break; case 3: $numthrees++; break; case 4: $numfours++; break; case 5: $numfives++; break; } // end switch } // end for loop //check for a pair if ($numpairs == 1) { print "You have two pairs!<br>\n"; $payoff = 4; } // end if //check for two pairs if ($numpairs == 2) { print "You have two pairs!<br>\n"; $payoff = 7; } // end if //check for a three of a kind and a full house if ($numthrees == 1) { if ($numpairs ==1) { //three of a kind and a pair is a full house print "You have a full house!<br>\n"; $payoff = 15; } else { print "You have a three of a kind!<br>\n"; $payoff = 12; } // end 'pair' if } // end 'three'if //check for a four of a kind if ($numfours == 1) { print "You have a four of a kind!<br>\n"; $payoff = 25; } // end if } // end if //check for a five of a kind if ($numfives == 1) { print "You have a five of a kind!<br>\n"; $payoff = 30; } // end if //check for flushes if (($numvals[1] == 1) && ($numvals[2] == 1) && ($numvals[3] == 1) && ($numvals[4] == 1) && ($numvals[5] == 1)) { print "You have a flush<br>\n"; $payoff = 20; } // end if if (($numvals[2] == 1) && ($numvals[3] == 1) && ($numvals[4] == 1) && ($numvals[5] == 1) && ($numvals[6] == 1)) { print "You have a flush<br>\n"; $payoff = 20; } // end if print "you bet £5<br>\n"; print "Payoff is $payoff<br>\n"; $cash += $payoff; // end evaluate function printstuff() { global $cash, $secondroll; print "cash: £$cash<br>\n"; //store variables in hidden fields print <<<HERE <input type = "hidden" name = "secondroll" value = "$secondroll"> <input type = "hidden" name = "cash" value = "$cash"> <input type = "hidden" name = "payoff" value = "$payoff"> HERE; } // end printstuff that's most of the coding if that helps
  6. Problem: When i click the button to re-roll the dices, the dices that haven't had their checkboxes ticked should only re-roll but they still all do. function rolldice() { global $die, $secondroll, $keepit; print "<table border = 1><td><tr>"; for ($i = 0; $i < 5; $i++) { if ($keepit[$i] == "") { $die[$i] = rand(1, 6); } else { $die[$i] = $keepit[$i]; } // end if //print out dice images print <<<HERE <td> <img src ="die$die[$i].jpg" height = 50 width = 50<br> HERE; //print out a checkbox on first roll only if ($secondroll == FALSE) { print <<<HERE <input type = "checkbox" name = "$keepit[$i]" value = "$die[$i]"> </td> HERE; } // end if } // end for loop Can anyone see the problem?
  7. //count the dice $numvals= arrays(6); for ($theval = 1; $theval <= 6; $theval++) { for ($dienum = 0; $dienum < 5; $dienum++) { if ($die[$dienum] == $theval) { $numvals[$theval]++; } // end if } // end dienum for loop } // end theval for loop Error: 'Fatal error: Call to undefined function arrays() in C:\Program Files\Abyss Web Server\htdocs\testt.php on line 100' line 100 = '$numvals= arrays(6);'
  8. yeh its working...well showing up now...thnx
  9. wouldn't I need that? and for the one at four of a kind I deleted that extra one but problem still there :S but thnx for that error
  10. That code is the problem...just change them to what you want
  11. True apache annoyed me for 6hours before I gave up and got Abyss
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.