Php Help !

Discussion in 'PHP' started by me4you, Jun 8, 2008.

  1. #1
    is there any code for random url?

    also want to check Browser url and set some condition is that possible?

    like if $url = something then print this one

    waiting for reply from php guys :)


    Thanks.
     
    me4you, Jun 8, 2008 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    For the second part, use $_SERVER variables. Simply, print_r($_SERVER) to see what element you need to handle.
    For the first part, what do you mean by random URL? If you want the user to visit random URLs, put them in an array and get a random value from it.
     
    Lordo, Jun 8, 2008 IP
  3. Trusted Writer

    Trusted Writer Banned

    Messages:
    1,370
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    160
    #3
    For the first part this is the answer,

    <? 
    
    //random URLs
    $urls = array("http://link1.com" ,"http://link2.com" ,"http://link3.com" ); 
    
    //text links for each URL
    $text = array("LINK 1" ,"LINK 2" ,"LINK 3"); 
            srand(time()); 
    
    //set the number in (rand()%3); for as many links you have added
            $random = (rand()%3); 
    echo ("<a target=\"_blank\" href = \"$urls[$random]\">$text[$random]</a>"); 
    
    ?> 
    Code (markup):
     
    Trusted Writer, Jun 9, 2008 IP
  4. kirpikinzi

    kirpikinzi Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    answer is yes,

    you can use a database to call random urls that is entered by you or someone else. this is just about adding urls to database.

    second part of question is : of course yes

    may be you should better find a link exchange scripts. you can find that code there.

    take it easy
    kirpikinzi
     
    kirpikinzi, Jun 9, 2008 IP