Using multiple OR in a php switch case. How to insert multiple condition in a switch case? [duplicate]

224
January 04, 2020, at 12:20 PM
This question already has answers here:
Counting table results: A PHP switch case that uses a radio button value (2 answers)
switch statement with two variables at a time (6 answers)
Closed 18 hours ago.

This is my first project as a student-trainee. It is an equipment monitoring system that keeps a record of computer equipment. This is part of code in a page that contains a filtering option and a table that displays a list of computer equipment. The filtering option contains several radio buttons that belong to two categories which are State and Condition. Please see the components of the two categories at the end of the post. The components are the radio button values.

The page reloads when another radio button is clicked similar to Facebook search. I wanted to count the number of equipment per Condition and State to be displayed beside the radio button label. BUT, the state radio buttons affect the counting of equipment. For example, New EQ is the type of equipment that was just entered into the inventory. When the New EQ button is checked and Available/Unassigned button is also checked, the table result will be filtered that will display results that contain equipment with a state that is New and a condition that is Available/Unassigned. The table result will be counted and will be outputted beside the radio button label which tells the user how many equipment are "New" and "Available/Unassigned". When another state radio button is clicked, such as Old EQ button, The displayed quantity of the Available/Unassigned equipment beside the label will change depending on the number of rows returned because the user changed the request to output equipment that is "Old" and "Available/Unassigned". BTW the state and condition are columns in the same table. This will happen to all the radio buttons. If the user clicks another radio button under the Condition category, such as the Assigned EQ button, the quantity of the Available/Unassigned displayed beside the label will change to 0 or zero because the user requested that the table result should display equipment that are New and Assigned, the equipment that is Available/Unassigned was not requested. If the user clicks "All condition" button, it will count the table rows that contain ALL the conditions which also has a data on its row a New state. The filtering process to display table results is already functioning. I am now working on outputting the quantities beside the radio button labels. Inserting multiple OR in a case seems to be wrong/impossible.

  <input type="radio" name="condition" value="Available/Unassigned" 
   onchange="javascript:handleRadiocond(this)" <?php echo $condition==='Available/Unassigned' ? 
   'checked' : '' ?>>(1)Available/Unassigned EQ:
       <?php
         switch($state AND $condition){
         case $state=="allstate" AND $condition=="allcondition":
         $sql3="SELECT *FROM eq_inv WHERE eq_condition='Available/Unassigned'";
         break;
         case $state=='new' OR $state=='old' OR $state=='Unknown state'  AND $condition=="allcondition":
         $sql3="SELECT * FROM eq_inv WHERE eq_condition='Available/Unassigned' AND ( eq_state='new' OR eq_state='old' OR eq_state='Unknown state')";
         break;
         case $state=='allstate' AND $condition=='Available/Unassigned':
         $sql3="SELECT * FROM eq_inv WHERE eq_condition='Available/Unassigned' AND ( eq_state='new' OR eq_state='old' OR eq_state='Unknown state')";
         break;
        case $state=='new' OR $state=='old' OR $state=='Unknown state'  AND 
        $condition=='Available/Unassigned':
        $sql3="SELECT * FROM eq_inv WHERE eq_condition='Available/Unassigned' AND ( eq_state='new' OR eq_state='old' OR eq_state='Unknown state')";
        break;
        case $state=='new' OR $state=='old' OR $state=='Unknown state'  AND $condition=='assigned':
        $sql3="SELECT * FROM eq_inv WHERE eq_condition='none'";
        break;
        case $state=='new' OR $state=='old' OR $state=='Unknown state'  AND $condition=='repair':
        $sql3="SELECT * FROM eq_inv WHERE eq_condition='none'";
        break;
        //I cant finish the code. Its too long and repetitive to do it for all conditions and the output is wrong
         }
              $result3=mysqli_query($conn,$sql3);
              $countavail=mysqli_num_rows($result3);
              echo "<label style='color:red;'><strong>".$countavail."</strong></label>";
              ?>
              <br>

Categories:

State: All state,new,old,unknown state

Condition: All condition,available/unassigned,repair,missing parts, missing eq, defective, refurbished,unknown condition

Rent Charter Buses Company
READ ALSO
array_merge(): Argument #2 is not an array

array_merge(): Argument #2 is not an array

After I updated any plugins, I saw this message on my QueryMonitor:

210
PHP require() relative path error

PHP require() relative path error

i have the following file structure:

178
Extract Data to Active Collab Tasks with Tags HTML - PHP

Extract Data to Active Collab Tasks with Tags HTML - PHP

I am trying to pull data from API for active collab, but in the body to the task exist tags HTML, causing a mess in the coding, anybody know what I can do?

160
Trying to join 3 tables from SQL but receiving error that a column is not found [closed]

Trying to join 3 tables from SQL but receiving error that a column is not found [closed]

Want to improve this question? Update the question so it's on-topic for Stack Overflow

163