Neutrality
Feb 24 2005, 02:49 AM
| | Here comes another one of Inspired's "amazing" PHP scripts. This little script lets you display a random message every time the user visits that particular page. It's not really that useful, but it does make the page a bit more "dynamic".
CODE $randMsg = array("Hi, welcome to my page!", "Hey you! Thanks for visiting!", "Bonjour, mon ami!", "So, do you like the site?", "Come one, come all!");
$MsgNum = count($randMsg); $MsgGenNum = floor(rand(MsgNum));
echo $randMsg[$msgGenNum];
You can edit those values in the array if you want. Add more if you so choose. Enjoy! |
Comment/Reply (w/o sign-up)
rejected
Feb 24 2005, 03:34 AM
Very nice, could you set it to be code snippets? Like CODE $randMsg = array("<img src='1.gif'>", "<img src='2.gif'>", "<img src='3.gif'>", "<img src='4.gif'>", "<img src='5.gif'>");
$MsgNum = count($randMsg); $MsgGenNum = floor(rand(MsgNum));
echo $randMsg[$msgGenNum];
Comment/Reply (w/o sign-up)
karlo
Feb 24 2005, 11:31 AM
Before, I readed the PHP manual. And I didn't see the floor function. What's the floor function?
Comment/Reply (w/o sign-up)
no9t9
Feb 24 2005, 03:36 PM
@ rejected yes, you can put random html code in there as well. that is how some people do random advertisment and banner rotation. @karlo i believe the floor function is simple to drop any decimals because he is using that number as an index for an array. (an array can't have decimal index number)
Comment/Reply (w/o sign-up)
ill
Feb 24 2005, 05:07 PM
It could also be used to display Random Quotes, which is something a lot of E/N sites do!
Comment/Reply (w/o sign-up)
(G)Steven
Jun 14 2009, 06:53 PM
Error In Code
Random Message Generator
The rand() function takes two parameters: minimum, and maximum.
$id = floor(rand(1,count($quotes)));
Echo $quotes[$id];
-reply by Steven
Comment/Reply (w/o sign-up)
(G)Ariel
Jul 30 2009, 11:31 PM
Heartfelt Apology
Random Message Generator
I'm a normal girl.Or so I thought. Sure I grew up decent I guess,I wasn't a tortured soul. I'm still not a tortured soul. But to allow yourself to get swallowed up by society isn't a very decent thing to do. Ignoring lady-like guidelines I single handedly flushed aspects of my life and those of others down the drain. Intense and maybe not consumable (if a word) to the human mind. But I am very proud. I'm proud of everything that has happened to me through the lessons i have taught others. Even the bad ones where I rudely broke their hearts or even just hurt their feelings. Because its easy to see now, how truly happy they all have become. Everyone finds happiness. Even if your the constant con' in every situation. You and your soul will find eternal happiness. I am Ariel Pirt, and this is my heartfelt apology to all those who couldnt find their happiness,who didn't make it. However I also hope this comes in handy as some sort of motivational type of regard. To each their own, and by that I mean...Be who you are.Because when it all comes down to it, your all you have.
-reply by Ariel
Comment/Reply (w/o sign-up)
(G)Arturo Garro
Aug 13 2009, 04:44 PM
**FIX**
Random Message Generator
The example is **REJECTED** it have some minor issues:
I fixed it as follow:
$randMsg = array("Hi, welcome to my page!", "hey you! Thanks for visiting!", "Bonjour, mon ami!", "So, do you like the site?", "Come one, come all!");
$MsgGenNum = floor(rand(1,count($randMsg)));
echo $randMsg[$MsgGenNum];
Thank you!
-reply by Arturo Garro
Comment/Reply (w/o sign-up)
unitechy
Aug 19 2009, 06:54 AM
I just tested this one on localhost, It does not display any message. Are you sure that CODE echo $randMsg[$MsgGenNum]; is correct line?
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : random, message, generator
- Php Form Generator Class
(2)
Php - Fetching Random Line From A Text File
and displaying it using AJAX/iframe (0) What you should know: HTML, PHP basics (executing php scripts) Examples: Using AJAX Using
iframe Download Examples Using this script you can display a random quote/fact every time a
visitor clicks the link. It happens dynamically without reloading the whole page. Useful for keeping
a site fresh and lively. For example, you can have it in "About Me" page of a website which is
rarely updated. All the quotes are stored in a text file separated by a line break. Although I have
included a sample collection, you are free to modify or create your own. Thanks to Davi....
How To Make A Random 7 Number Code?
(2) I am making a script in php, and for it I need to know how to make a random 7 digit code. I think it
has something to do with md5, but i am not sure. Thanks! EDIT- Can someone please change the title
to "How to make a random 7 digit code in php?" Thanks!....
Form Generator
(9) I am making a form generator like the one trap17 uses to make the code for website requests. well i
have everything set up, i studied the code from the trap17 generator and learned from it, then i
tried to make my own, but when i click the generate button, the code isnt filled out. if you would
like an example please visit my website at www.notapplicable.rifehost.com/forms/wrf.php the
problem is that it doesnt fill in the the answers. can anyone help? i will put credits on the
affilates page and on the gen pages. Here is my code: (this is the form) Website ....
Forms, Text Files, And Php For A Signature Generator.
Help a little. (1) Hello everyone! I am in need of some code a for a signature generator I am making. I am using
BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
html file that will have the user say what is on the sig! But now, I need help getting the form data
that is posted by the user to get into that sig! There is a file, sig.txt, where that tells the php
file what text will go on the sig. But how can I make the form data in the html file go into the
text file so it will go onto the sig? You might want to read BuffaloHELP's code. ....
Display Random File In A Directory
how to display a random file from a set directory. (9) hi, could someone please help me with this? I have some files in a directory and i want to know how
i can randomly display link/s to one or more of the files in my directory for download. But it must
not at any time display index.php which is also in the directory with the downloads. Thanks in
advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
alt="unsure.gif" />....
Dynamic Image / Signature Generator
a simple code to change text on an image (12) In search of dynamically changing quote, saying or all other types of text on an image I came across
a code that I have modified to fit my initial usage. This procedure requires two files and short
knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
CODE header("Content-type: image/png"); $image = imagecreatefrompng("../i....
Imap Problem
i want to check if the message is not seen (1) i'd like to know which message i had not been seen, so i searched the manual and fid 2 flags
says Unseen == 'U' || Recent == 'N' mean. but i don,t understand what does Unseen ==
'U' || Recent == 'N' mean(what he mean by flags )? i want to check if the
message is not seen, so how to do that? i tried CODE $inbox =
@imap_open("{mail.mysite.com:110/pop3}", "".$_SESSION ."+".$_SESSION ."", $_SESSION ) or
header("Location: error.php?ec=3"); $headers = imap_header($inbox, $x); if($headers->Unseen ==
'U' || $headers->Recent ....
Write Random Text To Image
PHP script help! (5) I'm trying to create a script that writes text to an image. CODE header("Content-type:
image/png"); $_phrases = array( "Test 1", "Test 2", "Test 3", "Test 4", "etc." ); $_rand_phrase =
$_phrases ; $_image = imagecreatefrompng("gmail.png"); $_user_width =
imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase); $_x_value = (200-($user_width + 113)); $_color =
imagecolorallocate($_image, 165, 164, 164); imagettftext($_image, 9, 0, $_x_value, 16, $_color,
"tahoma.ttf", $_rand_phrase); imagepng($_image); imagedestroy($_image); I can't see what
I'm doing wrong.. I....
Just About Completed My Own Message Board Source.
This one looks nice! (10) I've finally completed my message board source code! This one is very nice, and it has many,
many features. So if you can, please rate them and possibly register if you like this /wink.gif'
border='0' style='vertical-align:middle' alt='wink.gif' /> http://subzer0.net/boards/ ....
My Self-coded Message Boards
Rate them! (25) Alright, I used my great knowledge of PHP ( /tongue.gif' border='0' style='vertical-align:middle'
alt='tongue.gif' /> ) to code my own message boards! http://subzer0.net/php . The script runs
exceptionally fast and posting/leveling up works and most of the admin/mod features work. If you
want to register, then you would be able to explore these features more. If you don't, then
could you just rate them by the look of the index? >_> Please rate them from 1 to 10!....
Generate Random Phrases
...from a txt file (4) I have a question on how to generate random phrases (facts, quotes, etc) which the server will
randomly pick from txt file. Normally, I would use SSI to accomplish this task, but I recently added
a blog (Nucleus) to my site which uses PHP (.php file). So my question is, how can you display
random phrases in which the server will pick from a specified text file? Thanks! I saw a thread
very similar to my problem, but the code supplied by Inspired does not allow the server to select
the phrase from a file. The only reason I want this is because I have over 100 quotes,....
Php Form -fantastico Form Generator
Need overview re: How To use & setup (0) Hey Guys, Can anyone give me a quick overview on how to use the Fantastico FORM generator script in
CPanel. Need to set up several forms for website user input. Specifically, HowTo: 1) compose the
form ; 2)Where to put the form (ie. in which folder etc.); 3) how to link the form to buttons on my
other webpages; 4) output the form contents to e-mail boxes. Looked/searched for info &/or a
tutorial but can't find one. Anybody. Thanks RGPHNX....
Looking for random, message, generator
|
Searching Video's for random, message, generator
See Also,
|
advertisement
|
|