Php 表内div溢出滚动块
我有一个从数据库抓取的循环记录,我试图将这些记录放入一个溢出的div块中,以允许用户滚动每个记录的一个长列表,不知何故,当我显示下面的代码时,div块看起来是无序的,没有滚动,我如何将表放入溢出的div块中Php 表内div溢出滚动块,php,css,html,overflow,Php,Css,Html,Overflow,我有一个从数据库抓取的循环记录,我试图将这些记录放入一个溢出的div块中,以允许用户滚动每个记录的一个长列表,不知何故,当我显示下面的代码时,div块看起来是无序的,没有滚动,我如何将表放入溢出的div块中 <div style="overflow:auto;height:100px;width:358px;"> <table width="100%" border="1" cellpadding="3" cellspacing="0"> <
<div style="overflow:auto;height:100px;width:358px;">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr>
<td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
<td><?php echo $user_name; ?></td>
<td><?php echo $user_email; ?></td>
</tr>
<?php
$query2 = "SELECT * FROM sub_user where parent_user_id=".$row['user_id'];
$result2 = mysql_query($query2);
while($row2 = mysql_fetch_assoc($result2)){
$user_name = stripslashes($row2['user_name']);
$su_position = stripslashes($row2['su_position']);
$su_telephone = stripslashes($row2['su_telephone']);
$user_email = stripslashes($row2['user_email']);
?>
<tr>
<td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
<td><?php echo $user_name; ?></td>
<td><?php echo $user_email; ?></td>
</tr>
<?php
}
?>
</table>
</div>
你试过这个吗
<div style="overflow-y: scroll;height:100px;width:358px">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr>
<td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
<td><?php echo $user_name; ?></td>
<td><?php echo $user_email; ?></td>
</tr>
<?php
$query2 = "SELECT * FROM sub_user where parent_user_id=".$row['user_id'];
$result2 = mysql_query($query2);
while($row2 = mysql_fetch_assoc($result2)){
$user_name = stripslashes($row2['user_name']);
$su_position = stripslashes($row2['su_position']);
$su_telephone = stripslashes($row2['su_telephone']);
$user_email = stripslashes($row2['user_email']);
?>
<tr>
<td><input id="" class="" name="ids[]" type="checkbox" value="<?php echo $user_email; ?>" /></td>
<td><?php echo $user_name; ?></td>
<td><?php echo $user_email; ?></td>
</tr>
<?php
}
?>
</table>
我认为你的代码运行得很好。与您的问题无关,但除非您的数据已损坏,否则从mysql读取数据时不应使用stripslashes
,即使您在输入时使用了addslashes
。