2017-10-11 21 views
2

내 서버의 데이터로 채워진 테이블이 있습니다. 각 행에 대해 250 자까지 허용됩니다.서버 데이터가 포함 된 테이블의 HTML 테이블 워드 랩

이렇게하면 일부 셀에 매우 긴 시간이 걸릴 수있는 문제가 발생합니다. 이제 각 행의 문자를 특정 금액으로 제한하려고합니다.

어떻게 해결해야할지 모르겠다. 어쩌면 CSS 또는 PHP 함수?

내 코드 :

여기
<html> 
<head></head> 

<body> 
<table name = "userDetails"> 
    <tr> 
     <th>id</th> 
     <th>Gleitzeitrahmen</th> 
     <th>Abweichungen</th> 
     <th>Mehrarbeitervolumen</th> 
     <th>Mehrarbeit</th> 
     <th>Ausgleich</th> 
     <th>Mehrarbeit</th> 
     <th>Personalmassnahmen</th> 
     <th>Ueberstunden_abzusehen</th> 
     <th>Klaerungsbedarfe</th> 
     <th>Klaerungsbedarfe</th> 

    </tr> 
<?php 
$servername = "localhost"; 
$username = "root"; 
$password = ""; //your database password 
$dbname = "quartalsuebersicht"; //your database name 

$con = new mysqli($servername, $username, $password, $dbname); 

if ($con->connect_error) { 
    die("Connection failed: " . $con->connect_error); 
} 
else 
{ 
    //echo ("Connect Successfully"); 
} 

$sql_table_main = "SELECT id,name_Gleitzeitrahmen, name_Abweichungen, name_Mehrarbeitervolumen, name_Mehrarbeit1, name_Ausgleich, name_Mehrarbeit2, name_Personalmassnahmen, name_Ueberstunden_abzusehen, name_Klaerungsbedarfe1, name_Klaerungsbedarfe2 FROM dashboard"; 

     $result_table_main = mysqli_query($con, $sql_table_main); 
     if(mysqli_num_rows($result_table_main) > 0){ 

      while ($row = mysqli_fetch_assoc($result_table_main)) { 
       echo '<tr>'; 
       echo '<td>'. $row['id'] .'</td>'; 
       echo '<td>'. $row['name_Gleitzeitrahmen'] .'</td>'; 
       echo '<td>'. $row['name_Abweichungen'] .'</td>'; 
       echo '<td>'. $row['name_Mehrarbeitervolumen'] .'</td>'; 
       echo '<td>'. $row['name_Mehrarbeit1'] .'</td>'; 
       echo '<td>'. $row['name_Ausgleich'] .'</td>'; 
       echo '<td>'. $row['name_Mehrarbeit2'] .'</td>'; 
       echo '<td>'. $row['name_Personalmassnahmen'] .'</td>'; 
       echo '<td>'. $row['name_Ueberstunden_abzusehen'] .'</td>'; 
       echo '<td>'. $row['name_Klaerungsbedarfe1'] .'</td>'; 
       echo '<td>'. $row['name_Klaerungsbedarfe2'] .'</td>'; 
       echo '</tr>'; 
      } 
     } 
?> 
</table> 

</body> 
</html> 

답변

2

것은 나의 접근 방식이 사용하는 CSS를

th{ 
 
    
 
    max-width : 30px; 
 
    white-space : nowrap; 
 
    overflow : hidden; 
 
}
<table name = "userDetails"> 
 
    <tr> 
 
     <th >id</th> 
 
     <th >Gleitzeitrahm</th> 
 
     <th>Abweichungen</th> 
 
     <th>Mehrarbeitervolumen</th> 
 
     <th>Mehrarbeit</th> 
 
     <th>Ausgleich</th> 
 
     <th>Mehrarbeit</th> 
 
     <th>Personalmassnahmen</th> 
 
     <th>Ueberstunden_abzusehen</th> 
 
     <th>Klaerungsbedarfe</th> 
 
     <th>Klaerungsbedarfe</th> 
 

 
    </tr> 
 
    </table>