0

The boostrap table is inside the boostrap modal. I'm trying to display data in the table from the server which I hosted locally but the code , turns white when i introduce the while(){} loop. Below is my code.

  <?php while($products = $result->fetch_assoc()){
                    <tr class="table-success">
                    <th scope="row">
                      <div class="form-check">
                        <input class="form-check-input" type="checkbox" value="">
                    </div>
                   </th>
                    <td><?= some code?></td>
                    <td><?= some code?></td>
                    <td><?= some code?></td>
                   </tr>

                  } ?>
Phillips
  • 51
  • 1
  • 7

1 Answers1

0

You forgot to close the first PHP block with a ?>...

The first line should be <?php while($products = $result->fetch_assoc()){ ?> so that it goes back to non-PHP mode and outputs the HTML.

Also the last line should be <?php } ?>, so you just open the PHP block for the bracket and then close it again.

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • That is what I had done before but it did not make any difference. The code inside block is whitened – Phillips Jun 04 '21 at 13:18
  • fetch_assoc()){
    1 Infinix Smart 2 1000
    – Phillips Jun 04 '21 at 13:19
  • What do you mean by "whitened"? Is that something happening in your code editor? More importantly than whatever highlighting your IDE puts in, does the code actually work? It definitely won't work at all without the changes I've specified. – ADyson Jun 04 '21 at 13:20
  • `fetch_assoc()){ ` is still missing the `?>` after `fetch_assoc()){` ! Always double check your work. (P.S. If you'd just copied and pasted the code from my answer it would have been harder to make any mistakes) – ADyson Jun 04 '21 at 13:20