Forum Moderators: coopster
I have a template that has php includes (header.php, footer.php, menu.php, and content.php) Organizing those includes on the page is a series of tables.
So far, it will only display the data called in cantent.php, because its calling that page. I want it to display the content page depending on what menu item is selected, in one of the table cells(where it currently displays content.php).
Like <a href="" target="content.php"></a> or something similar.
Hope it makes sense.
Here is the code:
<html>
<head>
<title> Test PHP Template </title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<?php
include ("head.php");
?>
<!-- Table for Main Body -->
<table>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign="top" align="left" width="90">
<?php
include ("menu.php");
?>
</td>
<td width="1" bgcolor="lightskyblue" valign="top"> </td>
<td valign="top">
<?php
include ("content.php");
?>
</td>
<td width="1" bgcolor="lightskyblue" valign="top"> </td>
</tr>
</table>
</body>
</html>
[edited by: Afterlithe at 7:51 pm (utc) on Mar. 15, 2007]
insert this BEFORE the script generates ANY output!
<?php
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
header("Location:?page=firstpage");
}
?>
make your links like this
<a href='?page=newpage'>newpage</a>
where you include the content use
include($page.".php");
if you use subdirectories for you pages :
change header to
header("Location:?dir=firstdir&page=firstpage");
link to
<a href='?dir=newdir&page=newpage'>newpage</a>
and include to
include($dir."/".$page.".php");
this will work if you're not using frames
Warning: Cannot modify header information - headers already sent by (output started at /home/........) on line 19
which is this portion of code from above:
{
header("Location:?page=firstpage");
}
No other file that is being included has header information in it.
And this error on the content cell:
Warning: main(.php): failed to open stream: No such file or directory
This only happens on the index.php page, when you click on a link it displays the way its supposed to.
you might want to move the first php section (with the header part) to the top of the document. I.e. before your <html> opening tag
this would put the header call on line 8 in stead of 19
the error on the content call is because the url still doesn't contain the?page= part
if the header error still remains after this, you could use
if(!isset($_GET['page']))
{
$pageset = "false";
}
else
{
$page = $_GET['page'];
}
and the in the <head> of your script insert
<script langauge='javascript'>
<!--
str = '<? echo $pageset;?>';
if(str == 'false')
{
window.location = '?page=firstpage';
}
// -->
</script>
[edited by: lordbeezdje at 10:27 pm (utc) on Mar. 15, 2007]
I have a database page that displays all the records by 'id' on the page. Then links to the detailed page with more information. The list page displays everything fine and the link works, but how do I get the link to the detail page to display the correct 'id' from the db. Right now the detail page only displays the blank table where the content should be.
<a href="?page=press-release-archive-archive"><?php echo $row_list['title'];?></a>
There is the link that is on the list page, that directs the user to more information on the detail page depending on the 'id'
[edited by: Afterlithe at 7:52 pm (utc) on Mar. 16, 2007]
in that case you can again use the $_GET variable.
make you script echo a link like <a href='?page=press-release-archive-archive&releaseid=12'><?php echo $row_list['title'];?></a>
and in the press-release-archive-archive.php use $_GET['releaseid'] to get the right id for the press release
I hope this solves your problem, but if i misunderstood please correct me
Link looks like this:
<a href="../press-release-archive-detail.php?id=<?php echo $row_list['id'];?>"><?php echo $row_list['title'];?></a>
And when you click on it, it displays the selected id with info on a custom detal page.
[edited by: Afterlithe at 8:12 pm (utc) on Mar. 19, 2007]