$key = 1;
$row_count = 3;//一行多少列
$show = '<table>'.chr(10);
while($row = $db->get_array())
{
if ( ($key-1) % $row_count == 0)$show.= "<tr>".chr(10);
$show.= '<td>'.chr(10).'<a href="user/show_product.php?id='.$row['id'].'">'.chr(10).
(trim($row['pic'])==''?'':"<img src=img/{$row['pic']} width=150>").chr(10);
$show.= '<br />'.$row['name'].'</a></td>'.chr(10);
if ($key % $row_count == 0) $show.= "</tr>".chr(10);
$key++;
}
if (($key-1) % $row_count != 0) $show.= "</tr>".chr(10);
$show .='</table>';
动态生成表格,列数控制
最新推荐文章于 2021-08-25 19:02:22 发布