这是我的代码
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<td>Id</td>
<td>Articles Category</td>
<td>Update</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
<tr>
<?php
$con = new mysqli("localhost", "root", "", "whatever");
$sql = "SELECT id_kategori, nama_kategori FROM kategori";
$stmt = $con->prepare($sql);
$stmt->execute();
$stmt->bind_result($id, $cat);
while($stmt->fetch())
{
echo "<td>$id</td>";
echo "<td>$cat</td>";
echo "<td>Update</td>";
echo "<td>Delete</td>";
}
$stmt->close();
?>
</tr>
</tbody>
</table>
</div>
结果告诉我这个
“prepare($ sql); $ stmt-&gt; execute(); $ stmt-&gt; bind_result($ id,$ cat); while($ stmt-&gt; fetch()){echo”“; echo “”; echo“”; echo“”;} $ stmt-&gt; close();?&gt;“
我将它改为像这样的面向对象
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<td>Id</td>
<td>Articles Category</td>
<td>Update</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
<tr>
<?php
include 'connection.php';
$showall = new connection();
$showall->category();
?>
</tr>
</tbody>
</table>
</div>
我的结果就是这个
类别(); ?&GT;
有人可以解释我的代码出了什么问题吗?
答案 0 :(得分:1)
首先,您使用了非常糟糕的编码标准。您只是在HTML中间编写数据库连接?好的,您可以将HTML写为
#define BOOST_SPIRIT_DEBUG