Hey!
In this tutorial I will teach you how to make a random quote script - a script that will display a random script every time you load the page.
You'll need a server that allows you to run php files and some basic php knowledge!
First create two files - quote.php & quotes.txt.
First open quotes.txt and put your quotes in it this way
Quote1
::
Quote2
::
Quote3::Quote4
You just seperate each quote with "::".
Then open quote.php and input this code
<?
$quotes = array();
$content = file_get_contents('quotes.txt');
//gets contents of the quotes.txt file
$quotes = explode("::",$content);
//makes an array of quotes after they are seperated
$total_quotes = count($quotes);
//counts the total number of quotes
echo trim($quotes[mt_rand(0,$total_quotes-1)]);
//echo a random quote :)
?>
So..that's basically it!
It gets the total amount of quotes in quotes.txt and echoes a random one.
Don't be afraid to ask questions to me.
Cheers, Friiks!
Click here to see how my script works
| Link: |
| Downloads | 0 | |
| Rating |
| Log in to comment |
|
Brod Comments:121 Money:$135 |
Cool, now I have something to put in that empty spot in my site! :D |
| 24th September 2008 | | Report |
|
Samuraikill Comments:7 Money:$0 |
Lol, This is cool :) |
| 25th September 2008 | | Report |