在PHP中显示S3DB数据库 [英] Showing S3DB Database in PHP
本文介绍了在PHP中显示S3DB数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在有这张表:
I currently have this table:
<table class="table table-bordered table-edited">
<thead>
<tr>
<th>Image</th>
<th name="brand">Brand</th>
<th name="product">Product</th>
<th name="availability">Availability</th>
<th name="quantity">Quantity</th>
<th name="price">Price</th>
<th name="description">Description</th>
</tr>
</thead>
我需要帮助查看数据库表中的每个列在PHP表中。我只使用Xampp,每个PHP文件和s3db数据库都在那里。有人可以引导我通过我需要使它的PHP代码。
I need help in viewing the database table for each column in the PHP table. I am only using Xampp and each PHP file and s3db database is in there. Can someone please guide me through the PHP code that I need to make it work.
到目前为止,我试过这个:
So far i tried this:
<table class="table table-bordered table-edited">
<?php
$db = new PDO('sqlite:Products.s3db');
echo "<tr>";
echo "<th>   Brand   </th>";
echo "<th>   Product   </th>";
echo "<th>   Availability   </th>";
echo "<th>   Quantity   </th>";
echo "<th>   Price   </th>";
echo "<th>   Description   </th>";
echo "<tr>";
foreach($records as $r) {
echo "<tr>";
}
?>
</table>
推荐答案
此代码可以帮助您
<table class="table table-bordered ">
<thead>
<tr>
<th> Sl.No </th>
<th> Brand </th>
<th> Product </th>
<th> Availability </th>
<th> Quantity </th>
<th> Price </th>
<th> Description </th>
<tr>
</thead>
<tbody>
<?php
$db = new PDO('sqlite:Products.s3db');
$sql = "SELECT * FROM `tbl_name` ";
$result = $db->query($sql);
if($result){
while($row = $result->fetch(PDO::FETCH_ASSOC)){
echo '<tr>
<td>'.$i++.'</td>
<td>'.$row['brand'].'</td>
<td>'.$row['product'].'</td>
<td>'.$row['availability'].'</td>
<td>'.$row['quantity'].'</td>
<td>'.$row['price'].'</td>
<td>'.$row['description'].'</td>
</tr>';
}
?>
</tbody>
</table>
这篇关于在PHP中显示S3DB数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文