【问题标题】:Displaying the content of mysql in bootstrap table在引导表中显示 mysql 的内容
【发布时间】:2015-01-12 09:27:33
【问题描述】:

我实际上是在尝试在引导表中显示我的 mysql 表的内容。

我可以看到内容,但它只显示第一个内容,其他内容不在表格内。哪里错了?

实际的样子:

我的表.php

  <?php 
include('config/mysql.php');
$result = mysql_query("SELECT * FROM streams");
echo mysql_error();

?>
        <link rel="stylesheet" href="views/extra.css" />

<table class="tablesorter" cellspacing="0" > 
            <thead> 
                <tr> 
                    <th class="header">ID</th> 
                    <th class="header">Name</th>
                    <th class="header">Port</th>
                    <th class="header">Options</th>
                </tr> 
            </thead> 

            <tbody>
<?php while ($row = mysql_fetch_array($result)) { ?>
                 <tr>           
                    <td bgcolor="#D1FFC2"><?php echo $row["id"] ?></td>
                    <td bgcolor="#D1FFC2"><?php echo $row["streamname"] ?></td>
                    <td bgcolor="#D1FFC2"><?php echo $row["streamport"] ?></td>
                    <td bgcolor="#D1FFC2">Debug- Delete- Edit</td>
                        </tr>      
            </tbody> 
            </table>


<?php } ?>

【问题讨论】:

    标签: mysql sql twitter-bootstrap html-table


    【解决方案1】:

    把它从while $row = mysql_fetch_array($result) 循环中取出,放在结束之后。

     </tbody> 
                </table>
    

    并考虑使用 mysqlI 或 PDO,因为 mysql 功能已被贬低,即将消失。

    【讨论】:

      【解决方案2】:

      关闭“表格行”后的while &lt;TR&gt;

       <?php 
      include('config/mysql.php');
      $result = mysql_query("SELECT * FROM streams");
      echo mysql_error();
      
      ?>
              <link rel="stylesheet" href="views/extra.css" />
      
      <table class="tablesorter" cellspacing="0" > 
                  <thead> 
                      <tr> 
                          <th class="header">ID</th> 
                          <th class="header">Name</th>
                          <th class="header">Port</th>
                          <th class="header">Options</th>
                      </tr> 
                  </thead> 
      
                  <tbody>
      <?php while ($row = mysql_fetch_array($result)) { ?>
                       <tr>           
                          <td bgcolor="#D1FFC2"><?php echo $row["id"] ?></td>
                          <td bgcolor="#D1FFC2"><?php echo $row["streamname"] ?></td>
                          <td bgcolor="#D1FFC2"><?php echo $row["streamport"] ?></td>
                          <td bgcolor="#D1FFC2">Debug- Delete- Edit</td>
                              </tr>  
      
      <?php } ?>    
                  </tbody> 
                  </table>
      

      【讨论】:

        猜你喜欢
        • 2014-09-15
        • 1970-01-01
        • 1970-01-01
        • 2019-02-04
        • 2016-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-28
        • 2018-08-25
        相关资源
        最近更新 更多