【发布时间】:2014-10-19 07:42:21
【问题描述】:
我有一个 while loop 从 MySQL 表中获取数据。返回的行数未知。我想在loop 中的每个第 1 项和第 4 项中运行部分代码,例如:
while ($result = $stmt->fetch()) {
//Run on first row always, then repeat on the 4th item and so on.
echo '<div class="row">';
}
我该怎么做?
【问题讨论】:
-
简单的 if/else 带有存储循环迭代的标志变量
-
@MKhalidJunaid 你能详细说明一下吗?
标签: php mysql loops while-loop