1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Changing Title

Discussion in 'PHP' started by aaron_nimocks, Oct 15, 2005.

  1. #1
    Not sure if I can get all this infomation across that would be needed but...

    I am doing SEO on a site right now and I am to the point where I need to make the Title tags relevant. Basically doing one of these.

    <title>Site Name <? $product?></title>
    PHP:
    Now since the string that I need to use is no where on the .php page that would mean I guess I need to connect to the database then pull out the string I am looking for and then use it.

    Question is do I need this code before the <title> and could you by any chance provide me with a simple code that may work for this. :)

    I can read PHP and change it a little but I am not very good at writing it. If that makes since.

    Any help would be appreciated.
     
    aaron_nimocks, Oct 15, 2005 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    You should use a function that you can call with some sort of id being passed down to identify the page that is being called.

    Are you using PHP to build the page in the first place? There should be examples in the code of how to query it.
     
    sarahk, Oct 15, 2005 IP
  3. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    //put code here to pull the title from db if u r using db.
    //you can even include another php file here and get avariable defined there.
    $title = row['title']; //assuming row['title'] is what u pulled out from db.
    ?>
    <html>
    <head>
    <title>Sitename <?php echo $title; ?></title>
    </head>
    <body>
    </body>
    </html>
    
    PHP:
    simple prototype of what u shd be doing.
     
    king_cobra, Oct 15, 2005 IP
  4. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #4
    Thanks,

    One last question. There is a .php file that has the variable in it. What would the code look like to do that? Is it just an include?
     
    aaron_nimocks, Oct 15, 2005 IP
  5. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    include_once("filepath/filename.php");

    or just

    include("filepath/filename.php");

    or even require("filepath/filename.php") or require_once("filepath/filename.php") instead of the includes.
     
    king_cobra, Oct 16, 2005 IP