2013-07-22 25 views
1

我有一种表单,访问者可以在其中填写信息并在后端创建一个页面,以显示此信息供客户端查看。该表正在通过PHP进行填充。在其中一个字段中,访问者可以键入最多3000个字符的叙述,​​因为这可能会变得冗长,我想设置一个高度并添加一个滚动条。但是,我无法设定高度。无法在PHP生成的表格中设置TD高度

PHP

<?php get_header(); the_post(); ?> 

<h1>Prayer Requests</h1> 

<?php 

$mysqli = new mysqli('localhost', 'root', '', 'aln'); 
$query = $mysqli->prepare("SELECT `title`, `firstName`, `lastName`, `email`, `address`,  `city`, `state`, `zip`, `country`, `prayer`, `timestamp` FROM `prayerrequests` WHERE 1"); 
$query->execute(); 


$query->bind_result($title, $first, $last, $email, $address, $city, $state, $zip,  $country, $prayer, $timestamp) 
?> 
<table> 
<tr><td class="header">Title</td><td class="header">First Name</td><td class="header">Last Name</td><td class="header">E-mail Address</td><td class="header">Address</td><td class="header">City</td><td class="header">State</td><td class="header">Zip Code</td><td class="header">Country</td><td class="header">Prayer</td><td class="header">Date Submitted</td></tr> 
<?php 
while($query->fetch()) { 
echo "<tr><td>$title</td><td>$first</td><td>$last</td><td>$email</td><td>$address</td><td>$city</td><td>$state</td><td>$zip</td><td>$country</td><td>$prayer</td><td>$timestamp</td></tr>"; 
} 
?> 
</table> 

<?php get_sidebar(); ?> 

<?php get_footer(); ?> 

CSS

table { 
margin: 0 auto; 
border: 1px solid #000; 
background: #32458b; 
background: rgb(54, 79, 139); 
background: rgba(54, 79, 139, 0.5); 
border-spacing: 0; 
border-collapse: collapse; 
height: auto; 
width: 1000px; 
margin-bottom: 20px; 
} 

tr, td { 
border: 1px solid #000; 
color: #f1f1f2; 
height: 200px; 
overflow: scroll; 
} 

.header{ 
background: #32458b; 
background: rgb(54, 79, 139); 
background: rgba(54, 79, 139, 0.8); 
} 

回答

2

一般情况下,你会换表的DIV,然后大小DIV,并给它滚动条,而不是表本身。

+0

谢谢,我结束了刚刚添加一个div到叙述并设置该div的高度并添加了一个滚动条。 – Bucthree