Page 1 of 1

Small PHP Problem HELP!!

Posted: Sun Apr 27, 2008 11:44 pm
by needphp
I need to make the following script change style sheets when some body clicks the printer friendly link here is the script below but for some reason it wont work it just keeps loading the same style sheet.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<HEAD>
<TITLE> New Document </TITLE>


<?php
if($mode == 'print') $stylesheet = 'print.css';
else $stylesheet = 'style.css';
echo '<link rel="stylesheet" href="'.$stylesheet.'" type="text/css" />';
?>
</HEAD>

<BODY>

<a href="<?php echo $_SERVER['PHP_SELF'].'&mode=print'; ?>" title="" id="print"><img src="printer.gif" alt="" width="20" height="23" />Print</a>

<p>some random text</p>
</BODY>
</HTML>

Re: Small PHP Problem HELP!!

Posted: Mon Apr 28, 2008 12:46 am
by Frank Shi

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<HEAD>
<TITLE> New Document </TITLE>
 
 
<?php
$mode = $_GET['mode'];
 
if($mode == 'print') $stylesheet = 'print.css';
else $stylesheet = 'style.css';
echo '<link rel="stylesheet" href="'.$stylesheet.'" type="text/css" />'; 
?>
</HEAD>
 
<BODY>
 
<a href="<?php echo $_SERVER['PHP_SELF'].'?mode=print'; ?>" title="" id="print"><img src="printer.gif" alt="" width="20" height="23" />Print</a>
 
<p>some random text</p> 
</BODY>
</HTML>