dtihe8614 2015-03-27 15:36
浏览 21
已采纳

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

I am fetching data from Mysql database and populating them in a table. 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. 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>
  • 写回答

2条回答 默认 最新

  • doushantun0614 2015-03-28 10:45
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题