Re: checking for existance of $_SESSION variables

From: Date: Sat, 03 Apr 2004 22:27:16 +0000
Subject: Re: checking for existance of $_SESSION variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182262@lists.php.net to get a copy of this message
Hi Andy, Session Variable $guestbook exists? echo isset ( $_SESSION['guestbook'] ) ? 'yes' : 'no' ; Session Variable $guestbook exists and is not empty? echo ( isset ( $_SESSION['guestbook'] ) AND
       empty ( $_SESSION['guestbook'] ) === FALSE ) ? 'yes' : 'no';
-- red Andy B wrote:
hi... i have the following code and i need to check to see if $_SESSION['guestbook'] has been assigned to the session yet. if it has then use its values to create the combo box...if it hasnt then run the sql query and assign it to the session as well as fill the combo box with it... any ideas how? here is the current code: <? //combo_g.php combo box for guestbook //moduler: 100% reusable $guestbook=mysql_query("select * from rnjresort.guestbook order by Number ASC");?> <select name="edit"> <?if(!$guestbook){?> <option value="">(none)</option><?} else {?> <option value="ERROR">Select GuestBook listing</option> <?while($_SESSION['guestbook']=mysql_fetch_array($guestbook)){?> <option value=<?$_SESSION['guestbook']['Number']?>><?echo "(".$_SESSION['guestbook']['Number'].") ".$_SESSION['guestbook']['Name'];?></option> <?}}?> </select> sorry for the long listing of code... tnx


« previous php.general (#182262) next »