Jump to content

sarahspiteri

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by sarahspiteri

  1. OK here is all the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <?php function MySlot() { //my images $face="<p><img src=\"face.jpg\" width=\"250\" height=\"250\" alt=\"Face\" /></p>"; $hat="<p><img src=\"hat.jpg\" width=\"250\" height=\"250\" alt=\"Hat\" /></p>"; $cherry="<p><img src=\"cherry.jpg\" width=\"250\" height=\"250\" alt=\"Cherry\" /></p>"; $banana="<p><img src=\"cisk.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $faris="<p><img src=\"faris.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $jose="<p><img src=\"jose.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $iphone="<p><img src=\"iphone.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $edward="<p><img src=\"edward.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $twilight="<p><img src=\"twilight.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $duke="<p><img src=\"duke.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; $englandcup="<p><img src=\"englandcup.jpg\" width=\"250\" height=\"250\" alt=\"Banana\" /></p>"; //randomly choosing 1 of the four images for each of the three reels //for ($i=0; $i<10; $i++) { //Generate a number between 0 and 19 //$rand = rand(0, 65); $rand1= rand(0,65); $rand2= rand(0,65); $rand3= rand(0,65); //Assign image based on generated weight //Weights are: Face .4, Hat .3, Cherry .8, Banana .2, megan .6, faris .1, .twilight .2, .edward .5, duke . if ($rand1 >= 0 && $rand1<=4) { $reel1= $face; echo $rand; } elseif ($rand1 >4 && $rand1<= { $reel1 = $hat; echo $rand1; } elseif ($rand1 >8 && $rand1 <= 13) { $reel1 = $banana; echo $rand1; } elseif ($rand1 >13 && $rand1 <= 19) { $reel1 = $cherry; echo $rand1; } elseif ($rand1 >19 && $rand1 <= 21) { $reel1 = $englandcup; echo $rand1; } elseif ($rand1 >21 && $rand1 <= 30) { $reel1 = $faris; echo $rand1; } elseif ($rand1 >30 && $rand1 <= 38) { $reel1 = $duke; echo $rand1; } elseif ($rand1 >38 && $rand1 <= 45) { $reel1 = $twilight; echo $rand1; } elseif ($rand1 >45 && $rand1 <= 55) { $reel1 = $edward; echo $rand1; } elseif ($rand1 >55 && $rand1 <= 56) { $reel1 = $iphone; echo $rand1; } elseif ($rand1 >56 && $rand1 <= 65) { $reel1 = $jose; echo $rand1; } if ($rand2 >= 0 && $rand2<=4) { $reel2= $face; echo $rand2; } elseif ($rand2 >4 && $rand2 <= { $reel2 = $hat; echo $rand2; } elseif ($rand2 >8 && $rand2 <= 13) { $reel2 = $banana; echo $rand2; } elseif ($rand2 >13 && $rand2 <= 19) { $reel2 = $cherry; echo $rand2; } elseif ($rand2 >19 && $rand2 <= 21) { $reel2 = $englandcup; echo $rand2; } elseif ($rand2 >21 && $rand2 <= 30) { $reel2 = $faris; echo $rand2; } elseif ($rand2 >30 && $rand2 <= 38) { $reel2 = $duke; echo $rand2; } elseif ($rand2 >38 && $rand2 <= 45) { $reel2= $twilight; echo $rand2; } elseif ($rand2 >45 && $rand2 <= 55) { $reel2= $edward; echo $rand2; } elseif ($rand2 >55 && $rand2 <= 56) { $reel2 = $iphone; echo $rand2; } elseif ($rand2 >56 && $rand2 <= 65) { $reel2 = $jose; echo $rand2; } if ($rand3 >= 0 && $rand3<=4) { $reel3= $face; echo $rand3; } elseif ($rand3 >4 && $rand3 <= { $reel3 = $hat; echo $rand3; } elseif ($rand3 >8 && $rand3 <= 13) { $reel3 = $banana; echo $rand3; } elseif ($rand3 >13 && $rand3 <= 19) { $reel3 = $cherry; echo $rand3; } elseif ($rand3 >19 && $rand3 <= 21) { $reel3 = $englandcup; echo $rand3; } elseif ($rand3 >21 && $rand3 <= 30) { $reel3 = $faris; echo $rand3; } elseif ($rand3 >30 && $rand3 <= 38) { $reel3 = $duke; echo $rand3; } elseif ($rand3 >38 && $rand3 <= 45) { $reel3 = $twilight; echo $rand3; } elseif ($rand3 >45 && $rand3 <= 55) { $reel3 = $edward; echo $rand3; } elseif ($rand3 >55 && $rand3 <= 56) { $reel3 = $iphone; echo $rand3; } elseif ($rand3 >56 && $rand3 <= 65) { $reel3 = $jose; echo $rand3; } print("<table align=\"center\">"); print("<th colspan=\"3\" align=\"center\" style=\"color:#0C0; font-size:14px; font-family:'Comic Sans MS', cursive\"> The Sloth</th>"); print("<tr>"); print("<td width=\"33%\"><center>$reel1</td>"); print("<td width=\"33%\"><center>$reel2</td>"); print("<td width=\"33%\"><center>$reel3</td>"); print("</tr>"); print("</table>"); if($reel1 != $reel2 && $reel1 != $reel3 && $reel2 != $reel3){ if(isset($_POST['submit'])){ $amount= $_POST['amount']; $NoMatch = ($rand1/65 + $rand2/65 + $rand3/65)*$amount; echo $slothWin; echo $rand1; echo("space"); echo $NoMatch; } } } ?> </head> <body> <?php MySlot(); ?> <form id="form1" name="form1" method="post" action="index2.php"> <table align="center" width="74%"> <tr> <td width="100%" colspan="4" bgcolor="#28AD82"> <div align="center"> <input type="submit" id="submit" value="Spin!" name="submit"> </div> </td> </tr> </table> <table width="1005"> <tr align="center"> <td align="center">Amount bet: <input type="text" name="txt1" id="txt1" /> </tr> <tr align="center"> <td>You Win: <input type="text" name="txt2" id="txt2" value="<?php echo "$NoMatch"; ?>" /> <input type="text" name="amount" id="amount" /> </td> </tr> </table> </form> </body> </html>
  2. the code for rand1 rand2 and rand 3 is not important .. I just simply want to display a variable value in a textbox... this value is an integer and it is the result of a calculation. I want to display this result in a textbox ... I tried " " and it still doesnt work
  3. The actual code: This is not ALL of the code ... but the previous code is not important for this problem. This code is part of a function called MySlot() if($reel1 != $reel2 && $reel1 != $reel3 && $reel2 != $reel3){ if(isset($_POST['submit'])){ $amount= $_POST['amount']; $NoMatch = ($rand1/65 + $rand2/65 + $rand3/65)*$amount; echo $rand1; echo("space"); echo $NoMatch; } } } ?> </head> <body> <?php MySlot(); ?> <form id="form1" name="form1" method="post" action="index2.php"> <table align="center" width="74%"> <tr> <td width="100%" colspan="4" bgcolor="#28AD82"> <div align="center"> <input type="submit" id="submit" value="Spin!" name="submit"> </div> </td> </tr> </table> <table width="1005"> <tr align="center"> <td align="center">Amount bet: <input type="text" name="txt1" id="txt1" /> </tr> <tr align="center"> <td>You Win: <input type="text" name="txt2" id="txt2" value="<?php echo $NoMatch; ?>" /> <input type="text" name="amount" id="amount" /> </td> </tr> </table> </form> </body> </html>
  4. So I am trying to display the value of a variable in a text box. The value is an integer. So for example : $number1= 1+2; the above is written between the php tags. The following is found in the <form> tags: <input type="text" name="number" id="number" value="<?php echo $number1; ?>" /> when I run the page the textbox is just empty. I have no idea what I am doing wrong. Any help???
×
×
  • 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.