简体   繁体   English

如何使我的表格单元格自动适应Bootstrap 3中的内容?

[英]How to make my table cell auto fit to contents in Bootstrap 3?

I am fetching data from Mysql database and populating them in a table. 我正在从Mysql数据库中获取数据,并将其填充到表中。 However, i cannot seem to make the cell autofit to contents. 但是,我似乎无法使单元格自动适应内容。 I have tried width as the property of the table but i cant get it to work Would really appreciate your help. 我已经尝试过将width作为表格的属性,但是我无法使其正常工作,非常感谢您的帮助。 Thanks Here's what i have done so far 谢谢这是我到目前为止所做的

<div id="page-content-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">

                <table class="table table-bordered" style="width:100%">
                    <thead>
                      <tr>
                        <th><center>ID</center></th>
                        <th>Name</th>
                        <th><center>Email</center></th>
                        <th>Number</th>
                        <th>Package</th>
                        <th>Flexibility</th>
                        <th >Date</th>
                        <th>Departuring From</th>
                        <th>Departure Date</th>
                        <th>Destination</th>
                        <th>Arrival Date</th>
                        <th>Price</th>
                        <th>Consolidator</th>

                      </tr>
                    </thead>

                    <tbody>
                      <?php

                        $query = 'SELECT * FROM queries';

                        $result = mysql_query($query);

                        while ($row = mysql_fetch_array($result)) {
                            echo '<tr>';
                            echo '<td>'. $row['id'] . '</td>';
                            echo '<td>'. $row['name'] . '</td>';
                            echo '<td>'. $row['email'] . '</td>';
                            echo '<td>'. $row['contactnumber'] . '</td>';
                            echo '<td>'. $row['packagedetails'] . '</td>';
                            echo '<td>'. $row['flexibility'] . '</td>';
                            echo '<td>'. $row['datetoday'] . '</td>';
                            echo '<td>'. $row['departure'] . '</td>';
                            echo '<td>'. $row['dateofdeparture'] . '</td>';
                            echo '<td>'. $row['destination'] . '</td>';
                            echo '<td>'. $row['dateofarrival'] . '</td>';
                            echo '<td>'. $row['price'] . '</td>';
                            echo '<td>'. $row['vendor'] . '</td>';
                            echo '<td width=250>';
                            echo '<a class="btn btn-success" href="readquery.php?id='.$row['id'].'">Read</a>';
                            echo '&nbsp;';
                            echo '<a class="btn btn-success" href="updatequery.php?id='.$row['id'].'">Update</a>';
                            echo '&nbsp;';
                            echo '<a class="btn btn-danger" href="deletequery.php?id='.$row['id'].'">Delete</a>';
                            echo '</td>';
                            echo '</tr>';
                        } 
                        ?>  
                    </tbody>
                </table>

I never see you echo </tr> or </td> . 我从没见过您回声</tr></td> It would be helpful to give us an output of the HTML being generated by your while loop. 为我们提供由while循环生成的HTML的输出将很有帮助。

The problem was not with my table. 问题出在我的桌子上。 To make it work, i increased the width of my container in which my table was inside, and it worked 为了使其正常工作,我增加了桌子所在容器的宽度,并且该容器可以工作

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

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