简体   繁体   English

如何将行分成适合屏幕尺寸的部分

[英]How to break the row into parts to fit the screen size

I am using PHP to display a row from MySQL table based on the user input. 我正在使用PHP根据用户输入从MySQL表显示一行。

Since the table has many columns, I retrieve a lot of columns, for which the user has to scroll right to see all the data. 由于表中有很多列,因此我检索了很多列,用户必须向右滚动以查看所有数据。

I am using the following code to display the content to the page. 我正在使用以下代码在页面上显示内容。

$sql2="select * from student_information where student_id='$id'";
$result2=mysqli_query($conn,$sql2);

if($result2->num_rows > 0){
    echo '<table width="100%" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" border="1" class="db-table">';
    echo '<tr><th>STUDENT__FIRST_NAME</th><th>STUDENT__LAST_NAME</th><th>STUDENT_ID</th><th>ADDRESS</th><th>CITY</th><th>STATE</th><th>ZIP</th><th>COUNTRY</th><th>PHONE</th><th>DEPARTMENT</th><th>MAJOR</th>
<th>EMAIL</th><th>MAILING_ADDRESS</th><th>HEALTH_INSURANCE</th><th>CREDIT_HOURS</th><th>GROUP</th><th>GENDER</th><th>DOB</th><th>STATUS</th><th>NOTES</th><th>JOINED_ON</th></tr>';

    while($rowz2 = mysqli_fetch_assoc($result2)){
        echo "<tr>";
        foreach($rowz2 as $key=>$value){
            echo '<td>',$value,'</td>';
        }
        echo '</tr>';
    }
    echo "</table><br/>";
}
else {
   echo "<h2>No data based on the entered values</h2>";
}

How can I break out of the output row and into two rows, so that the output row will be displayed in two parts, so that it fits the screen, without the need to scroll right. 如何将输出行分成两行,以便将输出行分为两部分显示,使其适合屏幕,而无需向右滚动。

You can't assume the user screen has any defined width. 您不能假定用户屏幕具有任何定义的宽度。 it can range from a cell phone to an ultra wide monitor... better your table stays one record per line. 它的范围从手机到超宽显示器...最好让您的桌子每行保持一条记录。

You can use some css responsive table tricks though 您可以使用一些CSS响应表技巧

Check this out https://css-tricks.com/examples/ResponsiveTables/responsive.php 看看这个https://css-tricks.com/examples/ResponsiveTables/sensitive.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM