Counting table results: A PHP switch case that uses a radio button value

前端 未结 3 805
没有蜡笔的小新
没有蜡笔的小新 2021-01-28 16:47

I edited the post for a better understanding. This is my first project as a student-trainee. It is an equipment monitoring system that keeps a record of computer equipment. This

3条回答
  •  梦如初夏
    2021-01-28 17:15

    switch($state AND $condition) will evaluate to true or false depending of the values $state and $condition.

    So the only useful cases then are

    • case true
    • case false
    • case default

    In your case you should use if / else construct.

    Update

    Because asked in the comments how to write the conditions anyway in a switch construct see the nested code here:

    switch ($state)
    {
        case "allstate":
            if ($condition == "allcondition")
                $sql3 = "SELECT *FROM eq_inv WHERE eq_condition='Available/Unassigned'";
            break;
    
        case "new":
            if ($condition == "allcondition")
                $sql3 = "SELECT *FROM eq_inv WHERE eq_condition='Available/Unassigned' AND eq_state='new'";
            break;
    
        case "old":
            if ($condition == "allcondition")
                $sql3 = "SELECT *FROM eq_inv WHERE eq_condition='Available/Unassigned' AND eq_state='old'";
            break;
    
        case "Unknown state":
            switch ($condition)
            {
                case "Available/Unassigned":
                case "allcondition":
                    $sql3 = "SELECT *FROM eq_inv WHERE eq_condition='Available/Unassigned' AND eq_state='Unknown state'";
                    break;
    
            }
    }
    

提交回复
热议问题