PHP:
prepare(\"SELECT * FROM `users`\");
$stmt->execute();
$result = $stmt->get_result();
//
See my inline comments for how my answer works.
Also, you don't really need a prepared statement for your case and you should only include the columns that you intend to use in your SELECT
clause.
Code: (Demo)
$resultset=[
['avatar'=>1,'username'=>'A'],
['avatar'=>2,'username'=>'B'],
['avatar'=>3,'username'=>'C'],
['avatar'=>4,'username'=>'D'],
['avatar'=>5,'username'=>'E'],
['avatar'=>6,'username'=>'F'],
['avatar'=>7,'username'=>'G']
];
if(sizeof($resultset)){ // your num rows
$counter=0; // initialize the counter
foreach($resultset as $row){ // you while loop
if($counter%6==0){ // see if counter is evenly divisible by 6
if($counter){
echo "
Output: