自动换行不让数字也自动换行
问题描述:
我有这种有效的表格,唯一的事情是当用户在文本框数字中输入很多数字时
I have this form which is working The only thing is when user enters a lot of digits into the textbox numbers
示例:
12345678
3567892
1235674
36778883
566666678
35674748999
// with no spaces
它不想包装.我在网上四处张望,只显示了如何包装文字.
It does not want to wrap. I looked all over the net it only shows how to wrap text.
<html>
<?php
require_once("connect.php");
$stmt = $db->prepare("SELECT * FROM numbers");
$stmt->execute();
?>
<?php while( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { ?>
<table border='1'table-layout: fixed >
<br>
<tr>
<th>Id</th>
<th>numbers</th>
</tr>
<tr>
<td style="word-wrap: break-word;"><?php echo $row['numbers']; ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
答
尝试通过CSS指定表格的宽度.
Try to designate a width of the table thru css.
<table border="1" style="table-layout: fixed; width: 150px;">
<tr>
<th>Id</th>
<th style="word-wrap: break-word;">numbers</th>
</tr>
<?php while( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { ?>
<tr>
<td style="word-wrap: break-word;"><?php echo $row['id']; ?></td>
<td style="word-wrap: break-word;"><?php echo $row['numbers']; ?></td>
</tr>
<?php } ?>
</table>