2016-02-22 46 views
-2

我想显示复选框作为网格,而不滚动页面。我正在开发一个出席报告页面,显示学生姓名和复选框以及来自数据库的值。我想,以显示其在这样的网格:是否有任何方式显示表格内容像网格不滚动

this

我的代码这样表示:

this

我的代码:

<table border="1" cellspacing="2" cellpadding="5" summary=""> 
<?php 
    while ($row = mysql_fetch_assoc($res)){?> 
    <th> 
     <input type="checkbox" class="input" id="input 
     <?php echo $row['st_id']; ?>" 
     name="student[]" value="<?php echo $row['st_id']; ?>" 
     checked="checked" > 
     <?php echo $row['st_name'] ; ?> 
     <label for="input<?php echo $row['st_id']; ?>"> 
     </label> 
    </th> 

此代码需要两个名字并从数据库复选框ID ..任何人请帮助

+0

你可以尝试使用引导 –

+0

我可以把循环,自动把标签后 –

+0

是可以将部分计数。 [JSFIDDLE](https://jsfiddle.net/5sm64ts3/1/)\ –

回答

1

您可以使用浮动的DIV,而不是表:

​​

这将重新排序取决于用户的屏幕分辨率自动所有div。

+0

Thankyou mitkosoft为您的答案。它的工作 –

1

您可以使用它像这样:

<table border="1" cellspacing="2" cellpadding="5" summary=""> 
<?php 
$counter = 1; 
while ($row = mysql_fetch_assoc($res)){ 
    if($number==1) { 
     echo '<tr>'; 
    } 
    if($number %6 == 0) { 
     echo '</tr><tr>'; 
    } 
?> 
<th> <input type="checkbox" class="input" id="input<?php echo $row['st_id']; ?>" name="student[]" value="<?php echo $row['st_id']; ?>" checked="checked" > <?php echo $row['st_name'] ; ?> <label for="input<?php echo $row['st_id']; ?>"></label></th> 
<?php 
$counter++; 
if($number==0 || $number %6 == 0) { 
     echo '</tr>'; 
    } 
} 
?> 
</tr> 
</table>