I am in the process of attempting to set up an e-commerce store for my website. I plan on having it split into three categories (this part is already working), and then listing items from a MySQL database to a table.

I already am familiar with how to use the MySQL LIMIT function to limit results, but I want it to list all items from the database that match the category to the table and restrict it to a maximum of three items per row.

```
i.e.

Table

Item1 Item2 Item3

Item4 Item5 Item6

Item7 etc. etc.

```

Due to how few items I am listing per category, pagination is not necessary.

How would I even begin to attempt to set this up properly with a while loop? I saw something about a slice function with PHP, but not sure if that would fit my needs.

I have the base while loop working as intended, I just am not sure where to begin to break the loop apart into different rows in the table. I did a google search, and most I found was something related to slicing, but it wasn't related to MySQL fetch array functions.

```
$sql = $db->query('SELECT * FROM store_items WHERE store_cat = "Apparel"');
    if(is_object($sql) && $sql->num_rows > 0)
    {
        while($row = $result->fetch_array())
        {           
            echo '<tr>';
            echo '<td height="250">';
            echo '<img src="" alt="" height="180" /><br />'.$row['store_name'];
            echo '<br /><br />\$'.$row['store_price'].'<br />'.$row['store_desc'];
            echo '<br /><href="">Add to Cart</a>';
            echo '</td>';
            echo '</tr>';
        }
    }

```

I wish to have the while loop output the data from the database in rows of 3 items each. Right now, it only outputs the data in 1 row, unless I run a different query for each row (and just as many while loops).