The part of the code that checks thew number of columns is
if ($cols_count >= $cols) {
$cols_count = 0;
echo '</tr>';
}
As you can see, there is a comparison to see if $cols_count is greater than or equal to $cols, and if it is, then $cols_count is reset to 0
Near the top of your script are two constant variables
$rows = 3;
$cols = 3;
$cols is the $cols referenced in the if statement in the segment above, altering this to the appropriate value will allow you to change the number of columns in the grid. Altering the rows variable will have the same effect, but allow you to also alter the number of rows.
The code you presented has been written with this in mind, and is actually very easy to modify.
Cheers
Shawty