我有这个形式工作唯一的事情是当用户在文本框号码中输入大量数字时
示例:
12345678
3567892
1235674
36778883
566666678
35674748999
// with no spaces
它不想包装。我在网上看了它只显示了如何包装文字。
<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>
答案 0 :(得分:1)
尝试通过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>