用PHP和msql列出HTML [英] List in HTML with PHP and msql
本文介绍了用PHP和msql列出HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从数据库中获取数据到我设计的html表,但它给出的错误是我的代码:
i want to fetch data from database to a html table i design but it gives error here is my code:
<div class="ibox-content">
<?php
$servername = "localhost";
$username = "sehnoqta_userbmc";
$password = "u?gQ=uS%t;a?";
$dbname = "sehnoqta_bmc";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name, lastname, phone FROM regis";
$result = $conn->query($sql);
$conn->close();
?>
<table dir="rtl" class="table table-striped table-bordered table-hover dataTables-example" >
<thead>
<tr>
<th>Name</th>
<th>Last Name</th>
<th>Phone</th>
<th>Email</th>
<th>Acc Type</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo
"<tr><td>" . $row["name"]. "</td>
<td>" . $row["lastname"]. "</td>
<td>" . $row["phone"]. "</td>
<td>0795934799</td>
<td>Admin</td></tr>";
}
echo "</table>";
}
</tbody>
</table>
</div>
我的尝试:
i希望从数据库中获取数据到我设计的html表但是它给出的错误是我的代码:我的代码是否有任何问题????
What I have tried:
i want to fetch data from database to a html table i design but it gives error here is my code: is there any problem wih my code????
推荐答案
servername = localhost跨度>;
servername = "localhost";
用户名 = sehnoqta_userbmc跨度>;
username = "sehnoqta_userbmc";
密码 = ÙGQ = US%吨;一个跨度>;
password = "u?gQ=uS%t;a?";
这篇关于用PHP和msql列出HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文