The layout is block/modular so I need to apply a class to each of the divs. Issue is that when I preview in browser, after the code loops to begin at case 1 again - it skips one of the items from the db and displays the next item as case 1.
$result = mysqli_query($connection, "SELECT * FROM products");
$index = 1;
while($row = mysqli_fetch_array($result)) {
$float = "";
switch ($index) {
case 1: $float = "large-left";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 2: $float = "mini-left";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 3: $float = "mini-right";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 4: $float = "mini-left";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 5: $float = "mini-right";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 6: $float = "large-right";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 7: $float = "mini-left";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 8: $float = "mini-right";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 9: $float = "mini-left";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
case 10: $float = "mini-right";
echo "<div class=\"$float\"><img src=\"" . $row['product_imagepath'] . "\"/></div>";
break;
default: $index = 0;
break;
};
$index++;
};
mysqli_close($result);
?>
Any recommendations/alternative methods would be greatly appreciated!