3 column post in WP

I have been trying to search a code that would display a WordPress Post in 3 columns. But I haven’t found any of it that actually works the way I want it to be..

So I decided to create my own 3 column WordPress Post.

Here it is:

<table border="0" cellspacing="10" cellpadding="0" align="center">

<?php 

// You can change the cols to 4 if you want to have 4 columns.. or any number..
$cols = 3; // Number of Columns to be displayed
$colsdisp = 0; // No column display yet

?>

<?php if (have_posts()) : ?>

<tr>

<?php while (have_posts()) : the_post();  ?>

<?php

if ($colsdisp == $cols) {
print "</tr>\n<tr>\n";
$colsdisp = 0;
}

?>

<?php echo "<td>"; ?>

// Your contents here

<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>

// Contents Ends here

<?php echo "</td>\n"; ?>
<?php $colsdisp++; ?>
<?php endwhile; else: ?>
<p>Sorry, no products matched your criteria.</p>

<?php

$colsexec = $cols - $colsdisp;
for ($i=1; $i<=$colsexec; $i++) {

}
print "<td valign=\"top\"></td>\n";

?>
</tr>

<?php endif; ?>

</table>