You are assuming that the OP was asking for a way to output the columns of the database table as columns of the output table. When the OP stated that he wanted a "grid" view, I assumed that he meant he wanted each row of the database table as an entry in the grid.
Personally, I'd prefer using a list to approach the creation of a grid, but my post was simply to put yours into perspective.
Here's how to use a list:
CSS:
- ul.grid li {
-
float: left;
-
width: 64px;
-
height: 64px;
-
margin: 8px;
-
border: 1px solid #000000;
-
}
HTML:
- <ul class="grid">
-
<li><a href="#">Grid Item #1</a></li>
-
<li><a href="#">Grid Item #2</a></li>
-
<li><a href="#">Grid Item #3</a></li>
-
<li><a href="#">Grid Item #4</a></li>
-
<li><a href="#">Grid Item #5</a></li>
-
</ul>
PHP:
- echo '<ul class="grid">';
-
-
while ($data = mysql_fetch_object($result)) {
-
echo '<li><a href="' . $data->link . '">' . $data->title . '</a></li>';
-
}
-
-
echo '</ul>';