php用html表格输出数据库中的内容
<!-- 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>
<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>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: thinkphp 下拉框获取数据库数据
- 下一篇: 下拉框选中 默认选中(从数据库比较,用户本身的值
