ZoomCities IT Community Webmaster Forum

Full Version: Random Function & Text Overlay
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is kind of related to my other post, I'm assuming the solutions uses similar commands. There are actually a couple questions...

1)

I'd like to have the image header of my webpage change every time I refresh (there'll be repeats). I'll have a library of images for this.

How would I go about doing this?

2)

Also, how would I do this for text? I'd like to randomly display phrases from a library (txt file?).

3)

Lastly, how would I overlay the randomly chosen phrase on an image in a certain location? In this even possible?


Thank you very much, I hope I'm not being too bothersome!
Very possible Biggrin

Check out my sig to see most of this in action Smile

I use GD for the sig, I'll attach the source code see if you can get your head around how it works.

Edit: Then use http://www.phpfreaks.com/tutorials/105/3.php, something like this to add your image.
hmm, this is a bit confusing for me.

The signature php snippet: that's for randomly chosen phrases to image, right? Where are the phrases stored, and where is that referenced in the script?


As for the random image thing, I found a script on google: http://www.totallyphp.co.uk/scripts/random_image.htm
This part:

PHP Code:
include("../includes/quote.inc.php");
$mytext $Quote
Grabs the quote from a file that generates a random quote then puts it into the variable $Quote.
So how do I format the file that contains the quotes?
Mine looks like this:

PHP Code:
<?php

$quotes 
= array(
                
"Computers are useless. They can only\ngive you answers""\nPablo Picasso",
                
"Life is hard. It\'s even harder if\nyou\'re stupid""\nAnonymous",
                
"If at first you don\'t succeed, skydiving\nis not for you""\nFrancis Roberts",
                
"Never argue with an idiot. They drag\nyou down to their level then\nbeat you with experience""\nDilbert",
                
"Anyone who has never made a mistake has\nnever tried anything new""\nAlbert Einstein",
                
"It is better to remain silent and be thought\na fool than to open your mouth and\nremove all doubt""\nJonathan Swift",
                
"A computer once beat me at chess, but it\nwas no match for me at kick boxing""\nEmo Philips",
                
"Duct tape is like the force. It has a light\nside, a dark side, and it holds\nthe universe together""\nCarl Zwanzig",
                
"If Barbie is so popular, why do you\nhave to buy her friends?""\nAnonymous",
                
"Everything is funny as long as it\nis happening to somebody else""\nWill Rogers",
                
"If Stupidity got us into this mess, then\nwhy can\'t it get us out?""\nWill Rogers",
                
"I\'m desperately trying to figure out why\nkamikaze pilots wore helmets""\nDave Edison",
                
"Why don\'t they make the whole plane out\nof that black box stuff""\nSteven Wright",
                );

$totalQuotes = (count($quotes)/2);
$i = (rand(0,($totalQuotes-1)));
$i $i*2;

$Quote "\"".$quotes[$i]."\"".$quotes[$i+1];
$Quote stripslashes($Quote);
?>
I use it on other parts of my website so thats why its in a separate file, you could shove the two files together if you want. "\n" makes the rest of the quote move to the next line.
othersite Think that you are newbiie to PHP Language PLease refer more of php help at http://www.php.net
Reference URL's