working outside an 'include'
Posted: Fri Jan 26, 2007 3:34 pm
I wonder if anybody can help me work out the following. I have a single page in a small shopping cart and there are 2 categories of items for sale CD’s and books’. I want to run an ‘if statement’ looking for the categories and if it’s ‘1’ then I want the <h1> heading to read “CD’s for sale” and if its 2 I want it to read “books for sale”. Now my problem is that when I run the script below everything returns the correct result….
However what I really need to run in order to make the page display/format in the browser correctly is
But because the <?PHP if ($urlcategory = = 1) echo 'heading h1';?> etc is above the include statement it’s throwing the Undefined variable error, so can anyone give me a few ideas how this is normally resolved?
Many thanks
Code: Select all
<h1>???? for sale </h1>
<hr width="680" size="1" noshade>
<p><?php echo($cart->cartLinks());?></p>
<?php include("2/IncResults.php");?>
<?PHP if ($urlcategory = = 1) echo 'heading h1';?>
<?PHP if ($urlcategory = = 2) echo 'heading h2';?>Code: Select all
<h1> <?PHP if ($urlcategory = = 1) echo 'heading h1';?>
<?PHP if ($urlcategory = = 2) echo 'heading h2';?></h1>
<hr width="680" size="1" noshade>
<p><?php echo($cart->cartLinks());?></p>
<?php include("2/IncResults.php");?>Many thanks