Results 1 to 4 of 4

Thread: dynamic title per which statement

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default dynamic title per which statement

    I have a page that uses several if and elseif statements and I would like to adjust the title per what if/elseif statement is served.

    Is there anyway to perform this using a variable?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    All you would need to do is something like this:
    PHP Code:
    <?php
    $varTitleDetermind 
    "Hello";
    if(
    $varTitleDetermind != "GoodBye"){
    $varTitleDetermind "Hello, your IP is: ".$_SERVER["REMOTE_ADDR"];
    }
    else {
    $varTitleDetermind "Goodbye ".$_SERVER["REMOTE_ADDR"];
    }
    echo 
    "<title>".$varTitleDetermind."</title>";
    ?>
    And then you can switch that around to be completely random:
    PHP Code:
    <?php
    $varTitleDetermind 
    rand(0,1);
    if(
    $varTitleDetermind){
    $varTitleDetermind "This title is displaying because the \$varTitleDetermind is true";
    }
    else {
    $varTitleDetermind "This title is displaying because the \$varTitleDetermind is false";
    }
    echo 
    "<title>".$varTitleDetermind."</title>";
    ?>
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    xcoaster1 (07-03-2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    so if im calling the page with a $_GET where the variable is passed via the URL, I can use something similar to determine the title of the page.

    Each variable will return a different set of information, so for the year search, I would want the page title to list year and the page info and for the status, it would show active posts/page in the title.

    Code:
    if ($year >= "2003") {
     print table
    
    }elseif ($status == "1") {
     print table
    
    }else{
     print info

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, it should be this:
    PHP Code:
    if ($year >= "2003") {
     print 
    "table";

    }elseif (
    $status == "1") {
     print 
    "table";

    }else{
     print 
    "info";

    But, you've got the idea.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •