I want something like "Random Content Order script" but I don't want all the items to be displayed on the page. I just want a single block of html that randomizes every time the page is loaded. Is there something for that here?
I want something like "Random Content Order script" but I don't want all the items to be displayed on the page. I just want a single block of html that randomizes every time the page is loaded. Is there something for that here?
I know you can do this with php:
The basic way to do this is to create a text file with the text you want randomized (call it content.txt). Split each block of text with a line break.
Then use the following php:
Then print thePHP Code:$text_array = file('content.txt'); // This gets each line from the text file and holds it in an array
$text = $text_array[rand(0, count($text_array) - 1)]; // This gets the random content
$text = trim($text); // Trims extra whitespace
$textvariable into the html block e.g.
You can also use random MySQL queries in a similar way to this, but this should get you started.HTML Code:<div> <? print $text; ?> </div>
Last edited by jc_gmk; 11-27-2007 at 10:36 AM.
Client side wise, this script probably will do what you need: http://javascriptkit.com/script/scri...mcontent.shtml
Bookmarks