Results 1 to 5 of 5
  1. #1
    Full Member drumminlogan's Avatar
    Join Date
    January 17th, 2005
    Vancouver, WA
    I want to have one table on my site randomly load a different set of html everytime the page loads. There will be a featured product that will change between about 5 products,so the page will look a little different to users when they visit it. DOes anyone know of a good script that will do this. Thanks.

    "If you don't make mistakes, you aren't really trying" - Coleman Hawkins

  2. #2
    Join Date
    January 18th, 2005
    Try or do a search for Matt's Script Archive. I seem to remember that Matt had several scripts that generate random HTML. His stuff is rather old, but you can probably find updated versions at cgi-resources or at


    Stuff that makes me go, "huh?"

  3. #3
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    I have a random image snippet I've used on several of my sites which could be converted quite easily:
    <pre class="ip-ubbcode-code-pre">

    // print a random image. Don't forget ending slash!
    // setting $type to 'all' will return all images.
    // usage:
    // print getRandomImage('images/random/');

    function getRandomImage($dir,$type='random')
    global $errors;
    if (is_dir($dir)) {
    $fd = opendir($dir);
    $images = array();
    while (($part = @readdir($fd)) == true) {
    if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
    $images[] = $part;

    // adding this in case you want to return the image array
    if ($type == 'all') { return $images; }

    // Be sure to call srand() once per script
    srand ((double) microtime() * 1000000);
    $key = rand (0,sizeof($images)-1);
    return $dir . $images[$key];
    } else {
    $errors[] = $dir.' is not a directory';
    return false;
    } ?&gt;
    change the print() call to an include() call and change the filetypes in the eregi() call to those of your html snippet files.

    To use, make a directory to store all your random snippets in and call the function on that directory.

  4. #4
    Join Date
    January 17th, 2005
    you could also just place the html in a database and simply randomate it

    | System 0 | Affiliate-Talk | Affiliate-Review | Affiliate-Directory |- The Home of Affiliation [img]/infopop/emoticons/icon_wink.gif[/img]

  5. #5
    ABW Ambassador
    Join Date
    January 17th, 2005
    Sacramento, CA
    This can easily be done w/ javascript if you're not planning on anything too difficult...below is the code for random Steven Wright quotes...that guy is hilarious!
    If you want, PM me and I can send you a more complex version set up for affliliate linking or other images/banners...
    <pre class="ip-ubbcode-code-pre">
    &lt;SCRIPT LANGUAGE="JavaScript"&gt;
    var how_many_ads = 3; // change this depending on the number of banners
    var now = new Date()
    var sec = now.getSeconds()
    var ad = sec % how_many_ads;
    ad +=1;

    if (ad==1) {
    quote="I'd kill for a Nobel Peace Prize.";

    if (ad==2) {
    quote="Borrow money from pessimists - they don't expect it back.";

    if (ad==3) {
    quote="Half the people you know are below average.";

    document.write('&lt;TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0&gt;&lt;TR&gt;&lt;TD&gt;');
    document.write('&lt;FONT FACE=verdana,arial SIZE=1 COLOR=#000000&gt;');
    document.write(''+ quote +'');
    document.write('~Steven Wright');

    Supras | Celicas

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Random Products
    By jackson992 in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: February 21st, 2007, 01:00 AM
  2. HTML in datafeed stays HTML in file?
    By Nintendo in forum WebMerge (
    Replies: 1
    Last Post: August 17th, 2004, 09:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts