Re: accessing variable value



Sudhakar wrote:
i need help with accessing the value of a variable from a different
page.

i have an index.php file which has 2 files included to display header
and footer and the center portion changes based on the link clicked on
the footer.

header.php

<?php
echo "<h2> Text from header.php file </h2>";
?>

footer.php

<?php
$title="Title of Footer Page";
?>
<a href="index.php?page=web">Web Development</a> | <a href="index.php?
page=software">Software </a>

index.php

<?php
$pagename=$_GET["page"];
$title="Index page of Company name";
?>
<html>
<head>
<title><?php echo $title; ?> </title>
<meta name="keywords" content="<?php echo $keyword; ?>">
<meta name="description" content="<?php echo $pagedescription; ?>">
</head>
<body>
<?php include("header.php"); ?> <p> </p>
<center>This is the text in the center</center> <p> </p>
<?php
if($pagename=="web")
{
include("web.php");
}
if($pagename=="software")
{
include("software.php");
}
?>
<?php include("footer.php"); ?>
</body>
</html>

whenever i click the links for Web Development or Software which
appears from the footer a query string is passed to index.php I am
able to display the content of web.php and software.php using the if()
condition and include()
what i need to display is a different title for web.php and
software.php when a user clicks Web Development along with the content
i want the title of the page to change for SEO purpose. i have defined
$title differently in web.php and software.php however presently the
title being displayed for index.php when a user clicks web.php and
software.php the title is the same
"Index page of Company name" as this is defined in index.php and my
title tag is written as
<title><?php echo $title; ?> </title> however the title tag remains
the same whether i click web development or software link. how change
i change the code to display different titles.

i am doing this for SEO purpose so that different pages have different
titles and meta tags.


So you need to define $title based on the current page, before the call to $title.

actually there can be individual files with links to individual pages
however the people i am dealing with who developed the website want
the header and footer to remain so that a flash file does not have to
load each time an individual link is clicked.


Which has absolutely nothing to do with the loading of a flash file. The client never sees include files.

please advice.

thanks


Looks like maybe you should restructure your code. Place the header information in a function (preferably in an included file - it will break things up more). Then from your main web page file, call the header file's function, passing the title. That way the title is in the main web page and you don't have to keep changing your header or index page to account for a new title.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: [PHP] Links hierarchy maintenance
    ... difficulty for the function that will display the ... I have one include for the header, one for the footer and one for the navigation, which is usually called by the header. ...
    (php.general)
  • Re: Hidden Hdr/Ftr - using Print Layout - Not white sp prob
    ... Word will not open the editable Header and Footer display when I click on that item in the View menu. ... Tools>View>Text boundaries - The boundaries expand and contract to include the header and footers with and w/o markup. ...
    (microsoft.public.word.docmanagement)
  • Report Viewer with business ojbect data source + images
    ... The header and footer work fine but the image does not display. ... Private strHeader As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Different page numbers between header/footer
    ... When you insert page numbering using either Insert>Page Numbers or the ... display page numbers starting from 1. ... > header to start on page 22 and that apparently forces the ... > footer to start at page 22 as well. ...
    (microsoft.public.word.numbering)
  • Re: accessing variable value
    ... and footer and the center portion changes based on the link clicked on ... able to display the content of web.php and software.php using the if ... software.php when a user clicks Web Development along with the content ...
    (comp.lang.php)