Milbea Posted August 21, 2007 Share Posted August 21, 2007 Alrighty, I worked on this code for hours yesterday to get this game working. (I'm a newb, it was my first success with something this complicated). My problem is however, getting the result to display as I want it to. I used NVU to make what I wanted the end result to be, but when I pasted the code into the "echo" line it didn't work. Should I change the php game code, or can I code it so that each outcome automatically sends to the corresponding pages I made in nvu? Here's the code for the game: <html> <body> <title>Random Chance Hat Game</title> <?php //take their 10 gold. //if they don't have 10 gold, ignore the next section of code //generate a random number mt_srand ((double) microtime( )*1000000); $num = mt_rand (1,200); if ($num==1) echo " JACKPOT <br><br><img src= 'http://rpgsaga.com/games/jackpot.png'align=center>"; //add the jackpot elseif ($num>=2 and $num<=21) echo "You win 25 gold <br><br><br> <img src= 'http://rpgsaga.com/games/bigwin.png'>"; //add 25 gold elseif ($num>=22 and $num<=82) echo "You win 15 gold<br><br><br> <img src= 'http://rpgsaga.com/games/mediumwin.png'>"; //add 15 gold elseif ($num>=83 and $num<=153) echo "You win 10 gold <br><br><br> <img src= 'http://rpgsaga.com/games/smallwin.png'>"; //add 10 gold elseif ($num>=154 and $num<=184) echo "You win only 5 gold back. <br><br><br><img src= 'http://rpgsaga.com/games/blank.png'>"; //add 5 gold elseif ($num>=185 and $num<=200) echo "You lost your entire 10 gold <br><br><br><img src= 'http://rpgsaga.com/games/death.png'>"; else echo "You got nothin!"; ?> </body> </html> Here's the code for what I want the "jackpot" to look like: <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>10gold</title> </head> <body> <div style="text-align: center;"><big><big><big><big>Small win<br> <small><small>You win 10 gold!<br > < br> <b r> <br > <br > <br > <br > <br > <br > <br > Again?</small></small></big></big></big></big></div> <img style="width: 190px; height: 192px; position: absolute; top: 120px; left: 278px;" alt="10gold" src="http://rpgsaga.com/games/jackpot.png"> Quote Link to comment https://forums.phpfreaks.com/topic/66014-solved-how-should-i-display-images/ Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 Does nothing show up or do you get little boxes with X's in them? The code should work the way it is. Quote Link to comment https://forums.phpfreaks.com/topic/66014-solved-how-should-i-display-images/#findComment-330108 Share on other sites More sharing options...
Milbea Posted August 21, 2007 Author Share Posted August 21, 2007 The picture displays, but I'd like it to look as it does in the html code, or at least aligned center. If I put the html code in the echo command, nothing shows up. Quote Link to comment https://forums.phpfreaks.com/topic/66014-solved-how-should-i-display-images/#findComment-330111 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 above <?php, put <div align=center> and below ?>, put </div>. Quote Link to comment https://forums.phpfreaks.com/topic/66014-solved-how-should-i-display-images/#findComment-330116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.