PHP连接数据库输出赞赏列表表格

180it 2020-02-27 PM 2000℃ 0条
<style type="text/css">
table.tftable {font-size:15px;color:#333333;width:100%;border-width: 2px;border-color: #8FBC8F;border-collapse: collapse;}
table.tftable th { width: 30%; font-size:15px;
background: linear-gradient(to bottom right,#8FBC8F    , #008B8B);
border-width: 1px; padding: 8px;border-style: solid;border-color: #8FBC8F;text-align:left;}
table.tftable tr {background-color:#ffffff;}
table.tftable td {font-size:15px;border-width: 2px;  padding: 10px;border-style: solid;border-color: #8FBC8F;width: 30%;}
</style>

<body>
<table id="tfhover" class="tftable" border="1">
 <tr><th>时间</th><th>方式</th><th>备注</th><th>金额</th></tr>
 </table>

<?php
me = "localhost";//MySQL默认为localhost,端口号3306
$username = "数据库用户名";
$password = "数据库密码";
$dbname = "数据库名称";


// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

$sql = "SELECT 列名, 列名 FROM 表名";
$sql = "select * from 表名 where 列名 = '1' order by id desc";//倒序输出


  
$result = $conn->query($sql);
//$num = 1;  //循环序号,不会写反向,搁置
//".$num++."//循环输出


if ($result->num_rows > 7) {
    // 输出数据
  echo '<table id="tfhover" class="tftable" border="1">';
    while($row = $result->fetch_assoc()) {
         echo '<table id="tfhover" class="tftable" border="1">';
        echo "<tr><td> " . $row["order_time"]."</td><td>支付宝 </td><td>文章赞赏</td><td> " . $row["post_price"].    "</td></tr>";
        echo"</table>";
//这里是都已经套过表格了,需要请自行更改。
    }
} else {
    echo "0 结果";
}
$conn->close();
?>

来源:https://www.zmki.cn/4844.html

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

PHP连接数据库输出赞赏列表表格