-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|392|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Text and GUI's


 
HoboBen
Created : 13 September 2006
Edited : 13 September 2006
Language : FastBasic

SSI Random Content

Using Server Side Includes to display random content.

Good news for you webmasters with SSI enabled servers!

This great peice of code will give you an easy way to include rotating content, like a randomly chosen advert or a randomly chosen quote.

It has the advantage over JavaScript that it does not bloat out web pages with a ton of code. In JavaScript, all options for the random content must be given in the code, even if they are not used. With this method, only the needed content is served by the web server.

Here is the code...



This doesn't choose a "random" number as such, but depending on the time in seconds you load the web page at, it will display different content.

You may have

expr="$rand = /.n/"

for n=0 up to 9.

You also set a default for when you do not fill in all 10.

The target .shtml file would be, completely, with no head, body or doctype tags (it doesn't need any), something like:



Hope this helps someone!

 

Comments