1. If this is your first time on BYC, we suggest you start with one of these three options:
    Raising Chickens Chicken Coops Join BYC
    If you're already a member of our community, click here to login & click here to learn what's new!

php "if else" code help

Discussion in 'Random Ramblings' started by rebelcowboysnb, Mar 12, 2012.

  1. rebelcowboysnb

    rebelcowboysnb Confederate Money Farm Premium Member

    I dont know a lot about php so need some help.


    I need a code in my template file to use where I can have a set ad code on all pages except a few...



    something like

    if URL is "/page1.php" "/page2.php" or "/page3.php" do nothing

    if else include "ad code"

    Anyone know how to do that?
     
  2. call ducks

    call ducks silver appleyard addict

    4,260
    46
    253
    Mar 4, 2009
    waterville , canada
    Hey rebel, i can whip something up. The only thing is i am *not* sure it well work you may have to let me know any errors you get. Also you well have to used something like this... index.php?page=1


    I hate using a text area i can not [tab] correctley! It's anyoing!


    Code:
     
    <?php
     
    $url = $_GET['page'];
     
    if ($url == 1 /* If you would like to do a title instead of a page number replace 1 with strstr(pagename here) */ || /* || means or you can also use or  */ 2 || 3);
    {
    # do this
    print '<p>Hello the page id is 1 or 2 or 3 Thanks for stoping by!</p>';
    }
     
    /* You could also do an elseif statement 
     elseif ($url == 2) {
    print '<p>This content would be on page two</p>';
    // You could use an included like 
    include('url.html');
    or also include_once(''); require(''); could be used as well as require_once('');
    }
     elseif ($url == 3) {
    print 'anything here.....';
     }
    */
     
     else {
      print '<p>This would print your ad</p>';
     }
     
     
     
    ?>
    

    i am sure it could be done using an HTTP_HEADER_REQUEST but don't know a lot about it. For each page you would just add an elseif
     
  3. call ducks

    call ducks silver appleyard addict

    4,260
    46
    253
    Mar 4, 2009
    waterville , canada
    Hey rebel i well look into it and send you a file (Commented). I hope to be able to do this in the moring (As long as work does not need me)
     
  4. rebelcowboysnb

    rebelcowboysnb Confederate Money Farm Premium Member

    Thanks
     

BackYard Chickens is proudly sponsored by