evilgenius Posted March 19, 2007 Share Posted March 19, 2007 Hi, What I want is that in the jokes section of site, I want a jokes to appear daily (today's Joke) Whats the best way to do that. Would it be better if there is a link to Today's Joke & it pops up after clicking it, or its better that it takes you to the jokes page and displays it there.? Thanks in advance for any help. EG Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/ Share on other sites More sharing options...
per1os Posted March 19, 2007 Share Posted March 19, 2007 Whichever you prefer, I would say either the pop-up or it being displayed on the first window with a link to "more jokes" would be best, but this is not really a coding question is it? Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-210502 Share on other sites More sharing options...
DeathStar Posted March 19, 2007 Share Posted March 19, 2007 <?php session_start(); $number = rand(1,5); if ($numb = 1){ echo "First Joke";} elseif ($numb = 2){ echo "Second Joke";} elseif ($numb = 3){ echo "Third Joke";} elseif ($numb = 4){ echo "Fourth Joke";} elseif ($numb = 5){ echo "Fith Joke";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-210510 Share on other sites More sharing options...
evilgenius Posted March 20, 2007 Author Share Posted March 20, 2007 Errr...is it possible to have a file with jokes, say 100 in it. and then have the jokes generated from it, new one each day?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-210953 Share on other sites More sharing options...
DeathStar Posted March 20, 2007 Share Posted March 20, 2007 It is posible, and also with a database. Don't know how to do it with the file though. Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-210984 Share on other sites More sharing options...
flappy_warbucks Posted March 20, 2007 Share Posted March 20, 2007 Errr...is it possible to have a file with jokes, say 100 in it. and then have the jokes generated from it, new one each day?? ??? what i would do is make a fuile called jokes.txt and then use the fopen method to read the file line by line, that would then be loaded into an array that would have a random calling depending on the amount of jokes in the array i.e. rand(0,$jokes_in_array). that way yu can easly add more jokes, and they will always be random the more you have the more random it will be! Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-211013 Share on other sites More sharing options...
DeathStar Posted March 20, 2007 Share Posted March 20, 2007 Mind if I use that idea XD Good Idea.. Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-211088 Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 Didn't I learn that like the second day of programming? =) Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-211181 Share on other sites More sharing options...
Steppio Posted March 20, 2007 Share Posted March 20, 2007 The first step i ever took in the php world was this exact problem: http://www.sitepoint.com/article/php-amp-mysql-1-installation/1 that book should tell you how to do it with a database if you want, or i have alot of documentation on the fopen method, or failing that read about it at www.php.net. Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-211186 Share on other sites More sharing options...
DeathStar Posted March 20, 2007 Share Posted March 20, 2007 See there is the people who knows php beter than me and then there are people that does'nt know that things Quote Link to comment https://forums.phpfreaks.com/topic/43347-randomly-generating-a-joke/#findComment-211602 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.