php "if else" code help

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

  1. rebelcowboysnb

    rebelcowboysnb Confederate Money Farm

    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
    47
    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. rebelcowboysnb

    rebelcowboysnb Confederate Money Farm

    Yea, all that is confusing for a HTML person.
    I really need to learn more php...


    I need this code.

    <script type="text/javascript"><!--
    google_ad_client =""""""""""""""""""""""</script>

    To show on all pages but:

    http://alivestockauction.com/signinform.php

    http://alivestockauction.com/addmember.php

    http://alivestockauction.com/advance_search.php

    An

    http://alivestockauction.com/member_fb.php


    Google does not like there code on pages with very little actual content.

    If it helps you can email me a text file at [email protected]



    Right now I have the code in the general template file so it shows on all pages.
     
  4. call ducks

    call ducks silver appleyard addict

    4,260
    47
    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)
     
  5. rebelcowboysnb

    rebelcowboysnb Confederate Money Farm

    Thanks
     

BackYard Chickens is proudly sponsored by