在MySQL结果之间插入HTML代码

I want to insert a html code in between MySQL results.

My query

if($sql = $mysqli->query("SELECT * FROM  table Limit 20")){

    $row = mysqli_fetch_array($sql);

//Results display here    

    $sql->close();


}else{

     printf("There seems to be an issue. Please Trey again");;

}

Above query is pulling 20 results at a time. I want to insert <div class="block"></div>after pulling 3rd result and continue other results after that div (using a single query)

Can anyone point me how to do this.

As it simple as it gets. You just have to count each iteration and when it reaches 3 you print out the div element.

<?php
$mysqli = new mysqli("localhost","","","");

if ($mysqli->connect_errno){
    echo "Failed to connect to MySQL";
}

if ($result = $mysqli->query("SELECT * FROM table")) {
    $counter = 0;

    while ($row = $result->fetch_assoc()) {

        echo $row["______"];

        if((++$counter) == 3) {
            echo '<div class="block"></div>';
        }       
    }

    $result->close();
}

$mysqli->close();
?>