Categories
Development PHP

if else statement js nested inside php while loop statement – result appearing outside of loop/ not showing up

This is my code – I am trying to add a class upon a boolean result that is coming from the database. But when I run my code the echo’ing is happening outside of my loop and where it is supposed to be echo’ed is blank.
I believe this to be syntax but can’t seem to find the answer while combing through other answers.

while($record = mysqli_fetch_assoc($results))
{

    $invoice .= '<tr>
                    <th scope="row" class="displayField" ><a href="orderView.php?invoiceID='.$record['id'].'">'.$record['nOrderNum'].'</a></th>
                    <td class="displayField"><a href="#">'.$record['strOrderDate'].'</a></td>
                    <td class="displayField"><a href="#">$'.$record['nPrice'].'</a></td>
                    <td class="displayField"> 
               <div class="toggle-btn ';
                if($record['bOrderToggle'] != 1){
                   echo('');
                } else {
                       echo('active');
                   }
               $invoice .= '"><input id="switch" type="checkbox" checked class="checking" name="nInvoiceID" />
               <span class="round-btn"></span>
               </div>
            </tr>';
}

Leave a Reply

Your email address will not be published. Required fields are marked *