RE: [PHP] switch it button

From: Date: Wed, 23 Aug 2006 14:08:00 +0000
Subject: RE: [PHP] switch it button
Groups: php.general 
Request: Send a blank email to php-general+get-241047@lists.php.net to get a copy of this message
On 23 August 2006 12:45, Ross wrote: > At the moment I have this, but I want to change it to one > switch button > > <a href="<?php echo > $_SERVER['PHP_SELF'];?>?session_switch=1">switch it</a>. > I > > have tried but keep getting wrapped up in nested if-else statements. > Does anyone know how to make an efficient one button on-off switch. > > > > <? > $session_switch = isset($_GET['session_switch']) ? > $_GET['session_switch'] > > 0; > if ($session_switch==1) { > echo "on"; > > > //do something here > > <? > } > else { > > //do something else > > } > > > > <a href="<?php echo > $_SERVER['PHP_SELF'];?>?session_switch=0">off</a> > <a href="<?php echo > $_SERVER['PHP_SELF'];?>?session_switch=1">on</a> How about something like: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?session_switch=<?php $_GET['session_switch']?0:1 ?>">switch</a> Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

« previous php.general (#241047) next »