Re: switch statement

From: Date: Mon, 26 Feb 2001 03:10:32 +0000
Subject: Re: switch statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41636@lists.php.net to get a copy of this message
On Mon, 26 Feb 2001 13:20, Peter Houchin wrote: > I'm playing aruond with the switch statement trying to get one to work > for $submit > I have 2 forms on the one page (only one displays at a time) 1 is for > creating a new record in my data base the other is for > updating/changing values from the first form should there be any. So i > want it to switch between the 2 cases OK. Suppose the possible values for $submit are 'insert' and 'update'. [I assume those are values _you_ can assign to a submit button] Then switch($submit) { case 'insert': // Your insert stuff here break; //So it doesn't fall through to the next case case 'update: // Your update stuff here break; case default: // The page has somehow been called without a value (or an // inappropriate value) for submit // Error handling or whatever here } Does that make it clearer? or muddier :-) -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#41636) next »