我有这个代码
$query = mysql_query("SELECT * FROM my_table ORDER BY id ASC");
$i=0;
while($row = mysql_fetch_array($query)){
if ($i%2==0) {
<div class="main">
<div class="wrapper-main">
}
<article>test string1</article>
<article>test string2</article>
if ($i++%2==1) {
</div>
</div>
}
}
当结果计数是对数但如果是奇数,则“div”未关闭时,这项工作非常完美。如何解决?
我的结果必须是:
<div class="main">
<div class="wrapper-main">
<article>test string1</article>
<article>test string2</article>
</div>
</div>
<div class="main">
<div class="wrapper-main">
<article>test string1</article>
</div>
</div>