HazelRah Posted January 13, 2008 Share Posted January 13, 2008 Hi again!. No, dont be scared I need to know if it's possible to do this: I am going to have an image, (01.png) when you click on this image, it is random, 1 in 2 that you'll find some fake online money. When you find this money (random amounts!!!), this money will go on a counter on a different page. (not the type of counter that you refresh and +1 adds on But a counter that will add your money.) And i want this counter viewable by EVERYONE. And everyone to be allowed to add on to the counter. Lol Thanks in advance, Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/ Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 Of course it's possible =] For the 1 in 2 chance they find money, use the rand() function. To keep track of the money, just use a database. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438227 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 ehh..... could you give me another hint? im totally lost and this is important :'( Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438229 Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 Here is an example of how you could have them click on the image and they have a 1 out of 2 chance of getting the money. Is that enough to get you started? <?php if (isset($_GET['click'])){ $rand = rand(1,2); if ($rand == 1){ echo "You Win!"; //process their money here } else { echo "Awww, you lose"; } } ?> <p> <a href="index.php?click=yes"><img src="01.png"></a> Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438236 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 heck yes! thanks!. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438239 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Just make sure you learn how to use RAND and change those values. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438242 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 here it is: http://inferno.watershipdown.parahosting.net/Station/money.php Now, if i wanted it to say instead of: "MONEY FOUND" to say something like: "10GP MONEY FOUND"? So a random amount of money would be found. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438243 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Then just insert that variable before your text. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438247 Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 <?php if (isset($_GET['click'])){ $rand = rand(1,2); if ($rand == 1){ $amount_won = rand(1,100); echo $amount_won."GP MONEY FOUND"; //process their money here } else { echo "Awww, you lose"; } } ?> <p> <a href="index.php?click=yes"><img src="01.png"></a> Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438254 Share on other sites More sharing options...
steveclondon Posted January 13, 2008 Share Posted January 13, 2008 you will also perhaps need to the the $_SESSION[''] value if you want the site to remember how much money they and then add this on. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438257 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 Thanks!. Your all really great guys!. Now how do i make the money found get added to a counter lol Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438260 Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 you will also perhaps need to the the $_SESSION[''] value if you want the site to remember how much money they and then add this on. They want to add the money the person won into a pot of money won by all users. So I think a database would be the best way to go. Now how do i make the money found get added to a counter lol Database. Make a table like this TABLE counter -------------- winnerID - the userID of the winner of the money amount - the amount of money they won Now, whenever you want to get the total amount of money won, you would just do a query like this SELECT SUM(amount) as amount FROM counter Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438262 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 o.0 a database? Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438263 Share on other sites More sharing options...
Lamez Posted January 13, 2008 Share Posted January 13, 2008 do a google search on MySQL and here is some functions, and what not http://www.pantz.org/software/mysql/mysqlcommands.html good luck! Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438265 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 thanks! i need it. Well, the counter i need it added onto is a .txt file :S Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438268 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Yes, the DB would take the place of your .txt files and with this type of idea/site, you really need one. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438272 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 :S isnt there just a way to add it on to a .txt counter lol i hate MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438274 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 You can do flat file databases. But once you learn mysql, it's a piece of cake and so easy to use. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438275 Share on other sites More sharing options...
HazelRah Posted January 13, 2008 Author Share Posted January 13, 2008 You can? i didnt know that lol so how would i go about doing that then? Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438276 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Check the flat file database forum, should be something in there. But basically you are reading and writing .txt files. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438292 Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 Go through all the "file" tutorials on this site http://www.tizag.com/phpT/files.php Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438305 Share on other sites More sharing options...
HazelRah Posted January 14, 2008 Author Share Posted January 14, 2008 Check the flat file database forum, should be something in there. But basically you are reading and writing .txt files. I have looked. There's nothing there and no-one's replying to my post. Go through all the "file" tutorials on this site http://www.tizag.com/phpT/files.php I have looked through there, I already said i dont understand it. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438828 Share on other sites More sharing options...
tinker Posted January 14, 2008 Share Posted January 14, 2008 I think that you need to not try to do a massive and perfect project to start with. You need to go through those and other tutorials, having a little tinker with bits to see what the affect was, developing them, then by the time you done that you can put them all together to have a big whole. As, if I remember correctly, someone said to you yesterday, you won't understand or learn if someone else does it for you. Sorry to sound grumpy but there are a lot of people who come here and get others to do ALL their work for them, so this is a contentious issue, and I avoid the blatant non triers! It's sometimes hard, it get's easier, and it's very rewarding when it does... P.S. I've just looked through this post and it seems that you've not even posted any code whatsoever... Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438845 Share on other sites More sharing options...
revraz Posted January 14, 2008 Share Posted January 14, 2008 He didn't say Look there, he said go through them, as in, do them. Go through all the "file" tutorials on this site http://www.tizag.com/phpT/files.php I have looked through there, I already said i dont understand it. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438846 Share on other sites More sharing options...
pocobueno1388 Posted January 14, 2008 Share Posted January 14, 2008 That site is a tutorial site. It is meant to teach you what you want to learn. So if you want to learn it you need to follow the steps and actually read and apply what it's telling you to do. If you don't understand a function it uses, then look it up in the manual. Quote Link to comment https://forums.phpfreaks.com/topic/85855-another-really-hard-and-stupid-question/#findComment-438905 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.