php switch statement

See following:  

switch(intval($_POST['ua'])) {
                        case ">=1":
                              $_SESSION['height'] = $_POST['bdepth'];
                              $_SESSION['width'] = $_POST['bwidth'];
                              $_SESSION['length'] = $_POST['blength'];
                              $_SESSION['cuft'] = $_POST['tsqft'];
                              $qryu = "UPDATE visitor set height = " . $_SESSION['height'] . ", width = " . $_SESSION['width'] . ", length = " . $_SESSION['length'] . ", cuft = " . $_SESSION['cuft'] . " where vid = " . $_SESSION['vid'];
                              echo "qryu = " . $qryu . "<br>";
                              $resu = mysqli_query($link, $qryu);
                              $_SESSION['step'] = "2";
                        break;
                              case ">=2":      
                              $_SESSION['filt'] = $_POST['filt'];
                              $qryu = "UPDATE visitor set filtertration = " . $_SESSION['filt'] . " where vid = " . $_SESSION['vid'];
                              $resu = mysqli_query($link, $qryu);
                              $_SESSION['step'] = "3";
                        break;
                  }            

I have this code in an instance where I know that the value of $_POST'ua'] is 1.

It does not execute the case ">=1".

Is this an illegal expression for "case"?

Thanks
Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Switch is similar to a series of if() statements; these statements evaluate an expression, not a string literal.  They test for equality.  See if this makes sense...
http://iconoun.com/demo/temp_rkorts.php
http://iconoun.com/demo/temp_rkorts.php?ua=1
http://iconoun.com/demo/temp_rkorts.php?ua=2
http://iconoun.com/demo/temp_rkorts.php?ua=3
<?php // demo/temp_rkorts.php

/**
 * http://www.experts-exchange.com/questions/28711264/php-switch-statement.html
 *
 * http://php.net/manual/en/control-structures.switch.php
 */
error_reporting(E_ALL);

// I have this code in an instance where I know that the value of $_POST'ua'] is 1.

// HERE WE WILL USE $_GET FOR THE TEST - DEFAULT FOR OMITTED ARGUMENT IS ZERO
$ua
= !empty($_GET['ua'])
? (int)$_GET['ua']
: 0
;

switch($ua)
{
    case 1:
        echo 'It is One';
        break;

    case 2:
        echo 'It is Two';
        break;

    default:
        echo 'It is Neither One nor Two';
        break;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
Huh?  Case statements do not evaluate expressions at call.  They make either a numeric or character string comparison with the expression in the switch statement.  case ">=1" will Not be evaluated as an expression, only as a string.

To put it a different way... the 'switch' evalutes the expression in the switch part and looks for an exact match in the 'case' statements.  '1', as a number or string is not an exact match for ">=1".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.