randomly pick a page with chance for the page to be picked?

Discussion in 'Web Design and Development' started by dmmcintyre3, Jun 24, 2009.

  1. dmmcintyre3 macrumors 68020

    Joined:
    Mar 4, 2007
    #1
    I have referral links that I want a way to randomly pick between the some for my bookmarks. (with a script of corse)

    I would like to set a chance for each one to happen (like 25% 1 site 25% another site and 50% another) too.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You'd probably want to use PHP. To get the referrer URL use,
    PHP:
    $_SERVER['HTTP_REFERER']
    For random picking you can use something like,

    PHP:
    $pick rand(0100);
    if (
    $pick <= 25) {
      
    header('Location: somepage.html');
    }
    else if (
    $pick <= 50) {
      
    header('Location: otherpage.html');
    }
    else {
      
    header('Location: lastpage.html');
    }
     

Share This Page