格式化动态生成的复选框


Formatting dynamically generated checkboxes?

我有一个从XML文件中收集信息的系统,对于出口商,我一直试图创建一个系统,它从SQL表中收集唯一的印记,然后输出它们&将它用于导出查询,这样我们就可以只导出当时需要的内容&不是万能的。

我的代码做了上面的好,但我一直试图格式化它坐在一个表内,每7/8次迭代它开始一个新的表行,但我一直没有成功,在这一点上,167行目前我希望它看起来比一个庞大的列表(更容易使用)。

我目前拥有的代码如下:

    <table>
<form action="exporttrade.php" method="post">
<b>Please Select imprints you wish to Export for <client></b><br />
<?PHP
mysql_connect('server', 'user', 'password');
mysql_select_db("database");
    $sql ="SELECT distinct imprint FROM table";
    $results= mysql_query($sql);
    while( $imprint = mysql_fetch_assoc($results) ):
?>
    <tr><td><?php echo $imprint['imprint']; ?></td><td><input type="checkbox" name="imprint[]" value="<?php echo $imprint['imprint']; ?>"/></td></tr>
<?php endwhile; ?>

我一直在尝试使用我在网上看到的计数器和模函数,每第n行插入代码(在这种情况下,将是结束标记。这里有人知道你怎样才能成功地做到我所追求的吗?我只是有点难倒如何格式化当前:/

编辑-只是一个头设法得到这个工作,因为我想它现在使用以下内容:

$imprints=grab_array($sql);
foreach ($imprints as $imprint){
$imprint=$imprint['imprint'];
$counter++;
if($counter % 8 == 0){
    echo "</tr><tr>";
}
?>
<td><?php echo $imprint; ?></td><td><input type="checkbox" name="imprint[]" value="<?php echo $imprint; ?>"/></td>
<?PHP
   }    
?>

试试下面的代码。

<table>
<form action="exporttrade.php" method="post">
<b>Please Select imprints you wish to Export for <client></b><br />
<?PHP
mysql_connect('server', 'user', 'password');
mysql_select_db("database");
$count = 0;
    $sql ="SELECT distinct imprint FROM table";
    $results= mysql_query($sql);
    while( $imprint = mysql_fetch_assoc($results) ):
    if($imprint)
{
 count++;
}
while($count <= 8)
?>
    <tr><td><?php echo $imprint['imprint']; ?></td><td><input type="checkbox" name="imprint[]" value="<?php echo $imprint['imprint']; ?>"/></td></tr> 
<?php 
$count = 0;  echo '<tr><td> New Row after 8 </td> </tr>'?>
<?php continue ?>
<?php endwhile; ?>
<?php endwhile; ?>

你可以使用这个逻辑