我知道这对你们很简单,但我无法应用我的大脑。有没有更好的方式来处理这在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次。
任何更好的解决方案。谢谢。
将内容保存在你行,然后用行让他们['我'] –