Page 1 of 1

PHP Switch Case

New postPosted: Thu Mar 27, 2008 10:32 pm
by Ranman
# First create a file called test.html
# containing the following code.
#
<?
function main_menu () {
echo "<CENTER>main_menu function</CENTER>"; ?>
<? global $PHP_SELF; ?>
<FORM ACTION="<? echo $PHP_SELF; ?>">
<INPUT TYPE="radio" NAME="state" VALUE="Add"><B>Add User</B>
<INPUT TYPE="radio" NAME="state" VALUE="Edit"><B>Edit User</B>
<INPUT TYPE="radio" NAME="state" VALUE="Delete"><B>Delete User</B><P>
<INPUT TYPE="submit" VALUE="Submit">
</FORM><?
}
function back_link () { ?>
<A HREF="test.html">BACK</A><?
}
function add_users () {
echo "<CENTER>add_users function</CENTER>";
back_link();
}
function edit_users () {
echo "<CENTER>edit_users function</CENTER>";
back_link();
}
function delete_users () {
echo "<CENTER>delete_users function</CENTER>";
back_link();
}
switch($state) {
case "Add":
add_users();
break;
case "Edit":
edit_users();
break;
case "Delete":
delete_users();
break;
default:
main_menu();
}
?>


# Lastly point your web browser at
# http://www.your.domain.com/test.html


Demo!--->http://www.linuxguruz.org/tutorials/39Demo.php

Re: PHP Switch Case

New postPosted: Mon Dec 23, 2013 12:20 pm
by Joplin
PHP Offical Documentation
switch