创建网格而不是表格


Creating grid rather than a table

对于下表,我希望创建一个结果网格,而不是分页。

所以我想回显一组10个结果,然后继续向右处理200个像素。然后,在10个以上的结果之后,继续200像素的权利。

我该怎么做?

$query2 = "SELECT street1, city, state, zip, phone, website
FROM addresses
WHERE submissionid=$submissionid
ORDER BY street1 DESC";     

$result2 = mysql_query($query2);
$arr2 = array(); 
   echo "<table class='"commentecho3'">";

    while ($row2 = mysql_fetch_array($result2)) { 
        echo '<tr>';
        echo '<td>'.strtoupper($row2["street1"]).'</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>'.strtoupper($row2["city"]).', &nbsp;'.strtoupper($row2["state"]).'&nbsp;&nbsp;'.strtoupper($row2["zip"]).'</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>'.strtoupper($row2["phone"]).'</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>'.strtoupper($row2["website"]).'</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td></td>';
        echo '</tr>';
    }
    echo "</table>";

真的有必要在那里使用表吗?正如Webgal所建议的,使用浮动div可以非常容易地完成:在css中创建一个类.foo{float:left;padding-right:200px;}

更新PHP(这可以通过不同的方式完成):

$i=0;
echo('<div class="foo">');
while ($row2 = mysql_fetch_array($result2)) {
echo '<p>'.strtoupper($row2["street1"]).'</p>';
  .................................
$i++;
if ($i=10){
  echo('</div><div class="foo">');
}
}
echo('</div>');