我知道這對你們很簡單,但我無法應用我的大腦。有沒有更好的方式來處理這在PHP中呢?
我想打印<p>
與依據n的值相同內容的n次。
<?php while ($row = mysqli_fetch_assoc($result)) { ?>
if($row['i'] == 1) {
<p>Content</p>
} else if($row['i'] == 2) {
<p>Content</p>
<p>Content</p>
} else if($row['i'] == 3) {
<p>Content</p>
<p>Content</p>
<p>Content</p>
}
如果$row['i'] == 100
那麼我必須寫100次。
任何更好的解決方案。謝謝。
將內容保存在你行,然後用行讓他們['我'] –