473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

accessing variable value

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.

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.

please advice.

thanks
Jul 19 '08 #1
1 1536
code green
1,726 Expert 1GB
Your logic is barmy. I think you need to read at least one php web deveplopment book.
You cannot expect a variable to be in scope from a file that is included later.
And you certainly can't change the header information already sent to the browser

Instead of the link calling itself why not link to the required scripts - web.php or software.php where each can have its own header information.

You should try to write scripts that keep the php logic and the html display in seperate files.
This makes for easier maintenance
Jul 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ms_chika | last post by:
Hi to all, I have this problem in xsl wherein i want to access a variable in javascript and use it my xsl. How would i access or use a javscript variable in my xsl file? Please help. ...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
19
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' );...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
5
by: nomail.thanks | last post by:
I apologize for the question in advance. I have lots of experience with lots of other languages, but now I'm trying to accomplish something with VB.NET Express. My experience with VB.NET express...
5
by: Andy | last post by:
I'm having trouble accessing an unmanaged long from a managed class in VC++.NET When I do, the contents of the variable seem to be mangled. If I access the same variable byte-by-byte, I get the...
3
by: Mitko Haralanov | last post by:
I have a Python module that I have written using the C API and I am having a problem accessing a dictionary from that module. Here is what I have done: 1. In my init function I call module =...
9
by: Michael | last post by:
Hello! I have a problem accessing the value of selected option. It works fine if i put fixed name of select box, but not if the name is variable. Can anyone help me with it? function...
16
by: s0suk3 | last post by:
This code #include <stdio.h> int main(void) { int hello = {'h', 'e', 'l', 'l', 'o'}; char *p = (void *) hello; for (size_t i = 0; i < sizeof(hello); ++i) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.