switch statement...

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
dmakris
Forum Newbie
Posts: 11
Joined: Tue Jun 03, 2003 7:58 am
Location: Greece

switch statement...

Post by dmakris »

Hello.
I am sending the switch statement i use.
Cases 1,2,3 are the results of a selection box that I use in my form.
What I need is NOT to print the values on screen (using the echo command) but save each value to a variable so I can use the value later.

Anybody can help?
Thanks in advance


switch ($tmethod) {
case "1":
echo= "value 1";
break;

case "2":
echo= " value 2";
break;

case "3":
echo= " value 3";
break;
}
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

ah values that come from a form, those you can find in $_POST and $_GET nowadays. You probably want to read the whole section, starting from http://www.php.net/variables

Code: Select all

if (isset($_POSTї'tmethod']))
{
    switch($_POSTї'tmethod'])
    {
         case '1':
            $value = "foo";
            break;
          case '2':   // fallthrough
           case '3':
              $value = "bar";
              break;
           default:
               $value = "default";
     }
}
Post Reply