限制表格行中的列数

I am populating an HTML table from a SQL database using php. What I want to do is, I want to limit the number of columns in one row to 4. I tried doing it with CSS using

table.posts{
border:10px;
width:100%;
columns:auto 4;
-webkit-columns:auto 4;

This is the code I have:

<table class="posts">
    <tr>
        <?php 
        $respost = mysqli_query($link,"SELECT * FROM posts WHERE post_author=$uid");
        while($rowpost = mysqli_fetch_array($respost)) { ?>
            <td>    
                <h3><?php echo $rowpost['post_title']; ?></a></h3>
                <h4><?php //echo $rowpost['post_content']; ?></h4>
            </td>
            <?php 
        }
        ?>
        </tr>
</table>

There is no problem with the data I get from the db. It's just that it all shows in one row. I want to limit this to just 4 items per row and then break and continue on the next row. What is a simple way to do this?

Try like this

<table class="posts">
    <?php 
    $respost = mysqli_query($link,"SELECT * FROM posts WHERE post_author=$uid");
    $row_count=0;
    $col_count=0;
    while($rowpost = mysqli_fetch_array($respost)) { 
     if($row_count%4==0){
        echo "<tr>";
        $col_count=1;
     }
     ?>
        <td>    
            <h3><?php echo $rowpost['post_title']; ?></a></h3>
            <h4><?php //echo $rowpost['post_content']; ?></h4>
        </td>
        <?php
        if($col_count==4){
           echo "</tr>";
        }
        $row_count++; 
        $col_count++; 
    }
    ?>
</table>