您的位置:首页 > 编程语言 > PHP开发

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

2013-08-02 13:28 543 查看
<!-- 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: