for the search, my way to preload images! haha

Search for in

Randomness with PHP

PHP Coding Tutorials | Submited Feb 23, 2008

Written by: Rev. B.

How to display random content on a webpage with php. Enjoy it :)

- Notes -


There's two files, one where you store the links, or quotes or whatever you decide to put (rand.php), and the page you're displaying it.

Basically...


In rand.php you add whatever content inside the "quotes", it can be links, images, quotes (what I used it for), it doesn't matter.


<?php
//For a link
$rand[] = '<a href="URL_HERE"> This is a link </a>';

//For a quote
$rand[] = 'Real knowledge is to know the extent of one's ignorance.';

//For an image
$rand[] = '<img src="IMAGE_URL_HERE" />';


srand ((double) microtime() * 1000000);

$random = rand(0,count($rand)-1);

<? echo "<p>" . $rand[$random] . "</p>"; ?>
?>


And add this into the page you want it to display on::.

<?php include "rand.php"; ?>



More


To add more of whatever content you added just toss more of these in the rand.php file:
$rand[] = 'blahh';

tags Tags: random content quotes images and or links with php

3Thumbs up  Thumbs down0

Related Tutorials
How to Create Scroll Boxes
Hide Navigation Bar
Polaroid Effect for Friend Space
Creating Links
Stylizing the name with borders.
Animating Candle Flame
3D effect Border
Adding Glitter to Images
Artistic Color Isolation
Images in HTML
5 Minute Fudge
Image filters for IE
CSS Elements
Creamy Corn
Hiding tables on your profile
CSI
Precursor Orb Locations-Jak 3
Survivor
Orange Dream
Image as a border
1 Comments
  dave ~ 05/02/08, 2:13pm
Picture..
[BoyDrool]

1 


Sorry, you have to be a member to comment tutorials