Page 1 of 1

Help Generating Dynamic Page Titles

Posted: Sun Nov 01, 2009 8:43 pm
by aweb
I am having trouble figuring out the best way to implement dynamic page titles within my site. Currently, my header file looks like this:

Code: Select all

<title><?php if(isset($title)) { print $title; } else { print "other title goes here"; } ?></title>
And within the site pages I have defined

Code: Select all

$title "unique page title here"
 
However I have a categories.php that the 30 or so categories are pulled from, so I need a new way of generating the titles since the pages are all generated from this one file.

At the top of the categories.php the database connection file is included along with the header and to display the given category, the id is defined:

Code: Select all

$id=$_REQUEST['id'];
And if this helps, the category lists are generated later with the following:

Code: Select all

<?
                    $servcat=mysql_query("select * from We_ServiceCategory_tbl ");
                    if(mysql_num_rows($servcat)>0)
                    {
                        while($rscat=mysql_fetch_assoc($servcat))
                        {
                    ?>
                        <a href="categories.php?id=<? echo $rscat['Category_Id'];?>" ><? echo htmlentities($rscat['Category_text']);?></a>
Any ideas on what would be the easiest way for me to get this working?

Thanks

Re: Help Generating Dynamic Page Titles

Posted: Sun Nov 01, 2009 10:40 pm
by Christopher
Do you want the title to contain all of the category names? If so, concatenate the title from each fetched row to the $title string.

Re: Help Generating Dynamic Page Titles

Posted: Mon Nov 02, 2009 12:20 am
by guru2k9
Hi,

Is this a pure php code .
Then we can set using the file .Ie getting the url and the file name from the url.
Depending up on the file we have a dynamic title .

Thanks