Small PHP Problem HELP!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
needphp
Forum Newbie
Posts: 1
Joined: Sun Apr 27, 2008 11:40 pm

Small PHP Problem HELP!!

Post 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>
Frank Shi
Forum Newbie
Posts: 6
Joined: Thu Mar 13, 2008 4:03 am

Re: Small PHP Problem HELP!!

Post 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>
Post Reply