0
所以我試圖做到這一點..rowCount時基於行值
$userID = $_SESSION['user_session'];
$stmt = $this->db->prepare("SELECT * FROM orrs");
$stmt->bindparam(":id", $userID);
$stmt->execute();
$count = $stmt->rowCount();
echo
"<div class='table-responsive'>
<table class='table' border='1'>
<tr class='head'>
<h3>Snapshot</h3>
<th>Se</th>
<th>#s</th>
<th>Ae</th>
<th>Prt</th>
<th>Pin</th>
</tr>";
while($userRows=$stmt->fetch(PDO::FETCH_ASSOC)) {
if($userRows['stage'] == '1')
{
echo "<tr>";
echo "<td>" . "Newn" . "</td>";
echo "<td>" . $count . "</td>";
echo "<td>" . $userRows['aow'] . "</td>";
echo "<td>" . $userRows['pit'] . "</td>";
echo "<td>" . $userRows['pgin'] . "</td>";
}
else if($userRows['stage'] == '2')
{
echo "<tr>";
echo "<td>" . "Pendinn" . "</td>";
echo "<td>" . $count . "</td>";
echo "<td>" . $userRows['gfh'] . "</td>";
echo "<td>" . $userRows['pt'] . "</td>";
echo "<td>" . $userRows[trin'] . "</td>";
}
}
基本上,如果在該行STAGE = 1我想它來計算這些行,給我多少價值。如果STAGE = 2的值我希望它計算這些行並給我數字。
現在,它只是計算的所有行。所以兩者的IF的statment其計數是說2,當僅存在在每節1 ..
正如你看到的,雖然,Im做while循環。我不能做3個不同的while循環或它不會正確工作。 – Kmiles1990123
您可以使用相同的循環,我會更新我的答案 – Robin
完美工作,感謝您的幫助! – Kmiles1990123