title: odd results inside of a switch statement
body: <p>Thanks in advance to those who will have taken time to look at my issue.  I fetch results from a table that describe activities of a contractor.  There are a large number of True/False fields  and I seek only to display those that are true.  I create a field_name => field_type array and parse my display accordingly.  (apologies for the large code snippet.)</p>
  
  <pre><code>$result = $mysqli-&gt;query($visitsSQL);
  if ( $result-&gt;num_rows == 0 ){ // Visit records don't exist
      $_SESSION['message'] = "Cannot find any unpaid visits";
      header("location: error.php");
  }
  else { // unpaid visits exist
      $fields= array();
      while ($finfo = mysqli_fetch_field($result)){
      $fields [$finfo-&gt;name]= $finfo-&gt;type ; //this array holds field names -&gt; field types    
      }  //finish fetching keys and types
      echo "&lt;br&gt;";
      echo "&lt;br&gt;Begin visit records&lt;br&gt;";
      echo "&lt;div class='review_row'&gt; &lt;/div&gt;"; //this puts a thin line to separate visits
  
      while ($visit = $result-&gt;fetch_assoc()) {  //here's where each visit is compiled and sent to screen
  
          echo "&lt;div class='review_row'&gt;";  //this puts a thin line on the bottom to separate visits
  
       foreach ($fields as $k =&gt; $v) { 
  
          $field_name = $k;
          $field_type = $v;
          $field_data = $visit[$field_name];
  
          switch ($field_type) {
  
              case 1:   //The field is a True / False field
                  if ($field_data ==1){  //show the field only if the value is set to True
                     echo "I am a YES/NO field called " . $field_name . " &lt;br&gt;";  //This line is a test 
                     echo "&lt;span style='color: #009999;&gt; - " . $field_name . "&lt;/span&gt;&lt;br&gt;";              
                  }
                  break;
              case 4:  //The field is a double numeric
                     if ($field_data != null) {       //show the field only if the value is set to True             
                  echo "&lt;span style='color: #b38f00';&gt;" . $field_name . "&lt;/span&gt;  " . $field_data . "&lt;br&gt;";  
                     }
                  break;
              case 253: //A text field
                     if ($field_data != null) {                    
                  echo "&lt;span style='color: #b38f00';&gt;" . $field_name . "&lt;/span&gt;  " . $field_data . "&lt;br&gt;";  
                     }
                  break;
              case 254: //a Datetime field
                     if ($field_data != null) {                    
                  echo "&lt;span style='color: #b38f00';&gt;" . $field_name . "&lt;/span&gt;  " . $field_data . "&lt;br&gt;";  
                     }
                  break;
              default: { //field type is not represented above
                // do nothing so far  I take care of each field type above 
              }             
          }  //end of switch
      }  //end of foreach 
  }  //end of while loop for the query results
  echo "&lt;/div&gt;";
  </code></pre>
  
  <p>}  // end of if / else that determine if there are records to display</p>
  
  <p>The strange results occur in the "switch" statement where "case 1". My current test record has 7 YES/NO fields whose values are all set to 1.  They are</p>
  
  <ul>
  <li>Prepared evening meal </li>
  <li>Cleaned up evening meal dishes</li>
  <li>Shopped for groceries</li>
  <li>Washed and folded clothes</li>
  <li>Washed bedding</li>
  <li>Vacuumed carpets</li>
  <li>Swept kitchen floor</li>
  </ul>
  
  <p>I should get two "echo"s for each "field_type = 1": (1) my test echo and (2) what I eventually want to display, but for some reason they display alternately - see image below.  I've fought with this for two days, trying if/then parsing as well, but I come up with this "every-second-one" type of result.</p>
  
  <p><a href="https://i.stack.imgur.com/tSLQR.png" rel="nofollow noreferrer"><code>screenshot of output from query</code></a></p>
  
  <p>Thanks for any thoughts or direction.</p>