How to display ads only on pages with a certain url

Discussion in 'PHP' started by martyn11post, Mar 17, 2008.

  1. #1
    Hi, I am trying to display specific ads on certain pages with a certain url,
    e.g
    page www.xyz.com/index.php shows Ad code x
    page www.xyz.com/cheese/ shows Ad code y
    Any other page shows Ad code z

    e.t.c


    Many thanks,
    Martyn.
     
    martyn11post, Mar 17, 2008 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $url = $HTTP_SERVER_VARS['SERVER_NAME'] . $HTTP_SERVER_VARS['REQUEST_URI'];
    if (strstr($url, 'NEEDLE')) {
    //output ad y
    } else {
    //output ad z
    }
     
    GreatMetro, Mar 17, 2008 IP
  3. firman01

    firman01 Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    165
    #3
    or if you have so much url you can use switch()

     
    firman01, Mar 17, 2008 IP