duptiagnas 0 Newbie Poster

hi guys hope you are well, i on progress for making website but i have a problem with array and looping, how to stop looping when all data has been output.

<form method="POST" action="storedata_g6b.php">
    <table class="table">
        <thead class="thead-dark">
            <tr>
                <th class="col-3">id</th>
                <th class="col-7">nama</th>
                <th class="col-3">rank</th>
            </tr>
        </thead>
        <tbody>
        <?php
            $rank_b = 'B';
            $sql = "select t_empeval.id, t_empeval.nama from t_empeval Where t_empeval.grade='$c' and sect=CONCAT('$a','$b') order by t_empeval.v1 desc limit ".$var1.",".$var2."";
            $query = mysqli_query($koneksi, $sql);
            if(!$query)
            {
                die('SQL Error :' . mysqli_error($koneksi));
            }
            $b=0;
            while ($array_b = mysqli_fetch_assoc($query))
            {
                if(mysqli_num_rows($query) > 0)
                {
        ?>
                    <tr>
                        <td><input type="text" name="id_b[<?php echo $b; ?>]" value="<?php echo $array_b['id']; ?>"></td>
                        <td><input type="text" name="nama_b[<?php echo $b; ?>]" value="<?php echo $array_b['nama']; ?>"></td>
                        <td><input type="text" name="rank_b[<?php echo $b; ?>]" value="<?php echo $rank_b; ?>"></td>
                    </tr>
        <?php
                    $b++;
                }
            }
        ?>
            <input type="hidden" name="cotton_b" value="<?php echo $b; ?>" />
        </tbody>
    </table>
    <input type="submit" id="submit" name="submit"/>
</form>

in this case amount of data will be display is 2 row
example :
1 => a
2 => a

then if amount of data has been displayed then will break the loop and start other loop.
please englithment me, thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.