第1步:这是返回结果集的功能如何显示在PHP结果数据表
public function getLogById($reg_id) {
$stmt = $this->conn->prepare("SELECT * FROM tracking_log WHERE registration_id = ? LIMIT 5");
$stmt->bind_param("s", $reg_id);
if ($stmt->execute()) {
$result = $stmt->get_result()->fetch_all();
$stmt->close();
return $result;
}
else {
return false;
}
}
步骤2:在这里,我调用该函数
if(isset($_SESSION['registration_id'])){
$id = $_SESSION['registration_id'];
$result = $logs->getLogById($id);
echo "<table>";
foreach($tracking_result as $result)
{
foreach($result as $key => $value)
{
//echo "<li>$key : $value</li>";
echo "<tr class=\"active\" role=\"row\">";
echo "<td>Here I want to Display colum-1 of my DB-Table</td>";
echo "<td>"Here I want to Display colum-3 of my DB-Table"</td>";
echo "<td>Here I want to Display colum-4 of my DB-Table</td>";
echo "</tr>";
}
}
echo "<\table>";
}
当我print_r($result);
它显示我这样的结果
1
35124
2017-04-12 00:00:00
30.102261
-81.711777
2
35124
2017-04-10 00:00:00
30.102261
-81.711457
3
35124
2017-04-11 00:00:00
30.063936
-81.711307
4
35124
2017-04-12 00:00:00
30.102451
-81.711957
5
35124
2017-08-12 00:00:00
30.102261
-81.795777
请帮我解决这个问题。
解决什么问题?你期望输出是什么? –
你在哪里声明实际的表标签? – clearshot66
我想把表中的所有(5)记录从表格中放入五行html表格中。而已。问题是将结果集格式化为html表格,这正是我想要的。顺便说一句,我是新手。帮助将不胜感激。感谢 – s4starb4boy