我正在準備悄悄話系統準備悄悄話系統
問題的工作是在這裏,現在,它只會顯示一個即使有4到數據庫中。
我希望它一次顯示所有4個,而不只是其中的一個。
的問題都可以在這裏
http://billedeupload.dk/?v=rXFTj.png
$sql = "SELECT id, title, datoTime, checkpm FROM pm WHERE til=? ORDER BY datoTime DESC";
if ($stmt = $this->mysqli->prepare($sql))
{
$stmt->bind_param('i', $til);
$til = $_GET["id"];
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $title, $datoTime, $checkpm);
$stmt->fetch();
$count = $stmt->num_rows;
$stmt->close();
if($count >= 1)
{
?>
<tr>
<td><img src="/img/besked/reply.png" alt="svar" id="beskedu"></td>
<td><a href="/pm-set/<?php echo $id;?>/"><?php echo $title;?></a></td>
<td>
<?php
if($checkpm == 0)
{
?>
<a href="/pm-set/<?php echo $id;?>/"><img src="/img/besked/ulase.png" alt="ulæst" id="beskedu"></a>
<?php
}
else
{
?>
<a href="/pm-set/<?php echo $id;?>/"><img src="/img/besked/lase.png" alt="læst" id="beskedu"></a>
<?php
}
?>
</td>
<td><?php echo date("H:i - d, M - Y", strtotime($datoTime));?></td>
<td>Slet</td>
</tr>
<?php
}
else
{
?>
<div id="error"><p>Ingen besked</p></div>
<?php
}
}
else
{
echo 'Der opstod en fejl i erklæringen: ' . $this->mysqli->error;
}
你使用fetch而不是fetchAll你也似乎沒有循環遍歷結果 –
所以我必須做一個循環才能工作? – user3089022
是的,否則你只是返回最後的結果。也可以使用$ result-> fetch_assoc()而不是fetch。看看這裏http://stackoverflow.com/questions/7239391/how-do-we-use-mysqli-properly-to-fetch-all-the-records-from-table –