2014-11-10 2 views
2

I 사용자가워드 랩 번호 랩도

예는 텍스트 상자의 번호에 숫자를 많이 입력하면 유일한 것은 노력이 양식되고 있습니다

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

결국 어떻게되어야할까요? – Ghost

+0

테이블이있는 결과 페이지입니다. 숫자는 테이블을 줄 바꿈 대신 오른쪽으로 이동합니다. – Veronica

+0

출력용으로 사용할 경우 문자열로 캐스팅 할 수 있습니까? 또한 테이블에는 TD보다 많은 헤더가 있습니다. –

답변

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>