循環因此,我希望做到的是:內循環使用PHP
<div class="product-box">
<ul class="product-list">
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span>
</a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
</ul>
</div>
我有一個$griditems
這是從數據庫中排列。
我想顯示6。產品-box'es 6 <li>
的內線。這就是$griditems
通常情況下,我只想做了:
<div class="product-box">
<ul class="product-list">
<?php
$count=1;
foreach($griditems as $item)
{
if($count == 6) { break; }
?>
<li><a>.....</a></li>
<?php
$count++;
}
?>
</ul>
</div>
但是,這是行不通的在這種情況下,因爲我希望有6個這樣的.product-box類,並且在每個.product-box中應該是這6個項目,它們應該從彼此繼續而不是重複存在於$griditems
陣列中的前6個。
我該怎麼做?
請糾正我,如果我誤解了你的問題,但你試圖讓每個6項單獨列出,所有來'$ griditems'? – Matt 2012-07-31 17:29:08