SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do I display the page title?

    I am having problems with echo'ing the page title! I guess the problem is that the "echo" is before the "$title" in the final output of the page.

    I have no idea how to get the "$title" in front of the "echo" command. Can anyone help me???

    Here is how I organize my page:

    This is the first file that gets called(1.php):
    PHP Code:
    <?php $title "How to get rich in 5 minutes"?>
    <?php 
    include("authors.inc"); ?>
    <?php $author 
    "$author1"?>
    <?php 
    include("main_article_top.inc"); ?>
    Here is how to get rich!!
    <?php include("main_article_bottom.inc"); ?>
    main_article_top.inc:
    PHP Code:
    <?php include("header.php"); ?>
    <?php 
    echo $title?><br>
    By <?php echo $author?><p>
    "header.php" contain the title of the page (<title><?php echo $title; ?></title>)

    Thanks in advance
    Last edited by Shantra; Mar 28, 2002 at 11:08.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you echoing $title before or after making the connection to the db?
    . . . chris

  3. #3
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    atomicmunky,
    In this example I dont connect to the database at all. I guess the problem is that the echo is before $title in the final output!!!!
    Last edited by Shantra; Mar 28, 2002 at 09:20.

  4. #4
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have edited my question so that it would be clearer (I hope) to understand. Please help

  5. #5
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're going to have to put these in header.php

    PHP Code:
    $title "How to get rich in 5 minutes";
    $author "$author1"
    and then make 1.php:

    PHP Code:
    <?php
    include("main_article_top.inc");
    include(
    "authors.inc");
    ?>

    main_article_top.inc stays like this:
    PHP Code:
    <?php include("header.php");
    echo 
    $title?><br>
    By <?php echo $author?><p>
    does that make sense?
    . . . chris

  6. #6
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks atomicmunky,
    Yes, it makes sense but I cant use it. This way all of my pages would have the same title and author. All of this information HAS to be in the 1.php (the first loaded). All files except for 1.php are just include files.

    The reason for this structure is that I want to make custom articles (not just a news script) and an easy way to change the design of the whole site.

    So, my problem is to be able to do a echo command before the $title. It dont have to do that as long as it produces the same result.

    I have been turning my brain around for days on this one!!!!!!
    Last edited by Shantra; Mar 28, 2002 at 13:12.

  7. #7
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're not going to be able to echo the title before declaring it. it's just not logically possible.

    are you using a database? if you are then you can just echo $title where the article=1 or something like that.

    otherwise, maybe you can have a 1b.php which will have $title and $author in it. but that means xtra work.
    . . . chris

  8. #8
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    atomicmunky,
    I know, that's why I'm having this problem
    No, still not using a database for my articles. I may if that could help me though, and if I knew how to do that. The most important thing is that I'm not locked to one format (like most news scripts).

    My setup works just great except for this little title thing. It always have to be something


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
  •