牛骨文教育服务平台(让学习变的简单)
博文笔记

php用html表格输出数据库中的内容

创建时间:2013-08-02 投稿人: 浏览次数:4044
<!-- this table is show all info in database -->
      <table cellspacing="0" cellpadding="0" id="table2" style="display: none;">
      <tr>
<th style="width: 160px;">时间</th>
<th style="width: 240px;">邮箱</th>
<th style="width: 260px;">QR码</th>
<th style="width: 40px;">Send</th>
<th style="width: 240px;">视频</th>
      </tr>
      <?php
      header("content-type:text/html;charset=utf-8");
      //连接数据库
      $dbhost = "localhost"; 
      $dbuser = "root"; //我的用户名 
      $dbpass = "root"; //我的密码 
      $dbname = "video"; //我的mysql库名 
      $connect = mysql_connect($dbhost,$dbuser,$dbpass,$dbname); 
      if (!$connect) { 
      echo "不好意思,失败了!"; 
      echo "<br />";
      } 
      mysql_select_db($dbname, $connect);
      mysql_query("set names utf8");
    
      $result = mysql_query("SELECT * FROM data");
     
  
      while($row = mysql_fetch_array($result))
        {
        ?>
        <tr>
          <td style="width: 160px;"><?=$row["date"]?></td>
          <td style="width: 240px;"><?= $row["email"] ?></td>
          <td style="width: 260px;"><?=$row["qrcode"]?></td>
          <?php
          if($row["ifsend"] == 0) 
          {
           ?>
          <td style="background: #fff url("red.png") no-repeat center center; width: 40px;"></td>
          <?php
          }else{
           ?>
           <td style="background: #fff url("green.png") no-repeat center center; width: 40px;"></td>
           <?php } ?>
           <td><video src="../<?= $row["video"] ?>" preload="none" controls style="width: 240px;height: 135px;"></video></td>
        </tr>
        <?php
        
        }

        $len=count($arid);
        mysql_close($connect);
      ?>
      
      </table>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。