Hi there,
I am trying to create a PHP template so that all my pages are auto generated. Also I want to try and have a menu on the left.
I have already had all the pages working great using ppwizard.
Now I am trying PHP. My problem is that I can't get it to change the CSS class attribute between 'view' and 'notview'. Basically when a page is selected the menu on the left should show what page you are at. 'view' and 'notview'represent different css classes. It should change depending on what variable is passed in the URL.
I have tried the program two different ways and both give me the same error at about the same place. I have included both programs I made below. I probably have missed a semi colon or something. I have spent hour trying to figure it out. The worst part of it is most of the code is the same just copied and pasted with some variables changed.
I am really new at this so there is probably a much shorter and better way of accomplishing what i am trying to do. Any help is appreciated. All the code is below. The errors i get are highlighted where I believe I am getting them. I have counted the lines down but my full pages arent shown so the line numbers as shown here will not match. I will put the full html page if needed.
Code is shown below.
//-------------------menu css1 attempt1-------------------------------------------
<table class="menu">
<?php
if (!isset($_GET['p']))
{
echo('<tr><td><a class="view" href="index.php">Home</a></td></tr>');
}
else
{
echo('<tr><td><a class="notview" href="index.php">Home</a></td></tr>');
}
?>
<?php
if (($_GET['p'])==news)
{
echo('<tr><td><a class="view" href="index.php?p=news">News</a></td></tr>');
}
else
{ // page specified -> load content from relevant text file
echo('<tr><td><a class="notview" href="index.php?p=news">News</a></td></tr>');
}
?>
<?php
if (($_GET['p'])==new) *Parse error: syntax error, unexpected ')', expecting T_STRING or T_VARIABLE or '$' in Line 41
{
echo('<tr><td><a class="view" href="index.php?p=new">Whats New</a></td></tr>');
}
else
{
echo('<tr><td><a class="notview" href="index.php?p=new">Whats New</a></td></tr>');
}
?>
</table>
-------------menucss2attempt2
<table class="menu">
<?php
$view == 'notview';
if (!isset($_GET['p']))
{
$view == 'view';
}
echo('<tr><td><a class="$view" href="index.php">Home</a></td></tr>');
$view == 'notview';
?>
<?php
if (($_GET['p'])==news)
{
$view == 'view';
}
echo('<tr><td><a class="$view" href="index.php?p=news">News</a></td></tr>');
$view == 'notview';
?>
<?php
if (($_GET['p'])==new) Parse error: syntax error, unexpected ')', expecting T_STRING or T_VARIABLE or '$' on line 39
{
$view == 'view';
}
echo('<tr><td><a class="$view" href="index.php?p=new">New</a></td></tr>');
$view == 'notview';
?>
// -----------------Last Modified------------------------------
<?php
if (!isset($GET['p']))
{
$filemod = filemtime('includes/default.txt');
$filemodtime = date("F j Y h:i:s A", $filemod);
}
if (($GET['p'])==news)
{
$filemod = filemtime('includes/news.txt');
$filemodtime = date("F j Y h:i:s A", $filemod);
}
if (($_GET['p'])==new)
{
$filemod = filemtime('includes/new.txt');
$filemodtime = date("F j Y h:i:s A", $filemod);
}
</table>