php for loop leaves blank td in a table

  php

i am calling a for loop to get data from database with this code which is working fine but only with one problem

 <table class="table" style="color:#000 !important;">
                                    <tbody>
                                        <tr>

                                            <th>Question</th>
                                            <th>User Answer</th>
                                        </tr>
                                        <tr>

                                            </<?php

                                        for ($x = 0; $x <= 30; $x++) {
                                            ?> <td><?= $info['ans_'.$x]; ?></td>

                                        </tr>
                                        <tr>

                                            <?php

                                            $sales_quiz = mysqli_query($conn_quiz, "SELECT * FROM `sales_quiz` where `que_no` = '$x'");
$sales_que = mysqli_fetch_array($sales_quiz); ?>
                                            <td><?= $sales_que['que']; ?></td>

                                            <?php }; ?>

                                        </tr>

                                    </tbody>
                                </table>

the result is first td of 2nd data which is que is blank and for loop start counting it from 2nd row

enter image description here

i do create saprate for loop for question and answer but then table become broken.

pls help.

i am happy to provide any more info if u guys need

Source: Ask PHP

LEAVE A COMMENT