我想檢查下一個TWO行或ID是非NULL。PHP(codeigniter) - 如何檢查下兩行是否有價值?
因爲如果沒有成功兩個行或ID然後收入保持零。
foreach ($data as $row)
{
if(($row->id + 2) != NULL) //I don't know what is the correct statement here
{
echo "<tr>";
echo "<td>".$row->id."</td>";
echo "<td>".$row->username."</td>";
echo "<td>"."650.00"."</td>";
echo "<td>".$row->remarks."</td>";
echo "<tr>";
}
else
{
echo "<tr>";
echo "<td>".$row->id."</td>";
echo "<td>".$row->username."</td>";
echo "<td>".$row->income."</td>";
echo "<td>".$row->remarks."</td>";
echo "<tr>";
}
}
這是我想要實現的表格。
==================================
|ID | Username | Income | Remarks|
| 2 | user1 | 650.00 | |
| 3 | user2 | 650.00 | |
| 4 | user3 | 0.00 | |
| 5 | user4 | 0.00 | |
==================================
如果我添加一個用戶名,然後下一個輸出將是這樣的:
==================================
|ID | Username | Income | Remarks|
| 2 | user1 | 650.00 | |
| 3 | user2 | 650.00 | |
| 4 | user3 | 650.00 | |
| 5 | user4 | 0.00 | |
| 6 | user5 | 0.00 | |
==================================
和問題是什麼?錯誤?分享一些更多信息 – TommySM
當原始「IF」語句正在運行時,我所有行的輸出收入將爲650.00 –
您想檢查user2之後是否仍有後續記錄?我對嗎? –