<?phpfor($i=0;$i<3;$i++){?><div class="dptj1_coloum xxx<?php echo $i ?>"><?php$items = array(); $widths=273; $heights=273; $szzkj = explode(",",$_MODULE["szzkj"]);switch($_MODULE[huoqubaobei]){ case "1": $items = $itemManager->queryByKeyword($_MODULE[guanjianzi],$_MODULE[paixu],$_MODULE[geshu]); break; case "2": $arr = explode(',',$_MODULE[item_1]); foreach($arr as $value){ $item=$itemManager-> queryById ($value); array_push($items, $item); } break; case "3": $arr = explode(',',$_MODULE[cate_1]); $items = $itemManager->queryByCategory($categoryId,$_MODULE["paixu"],$_MODULE["geshu"]); break; case "4": $srtpdz = explode(",",$_MODULE["srtpdz"]); $srtpljdz = explode(",",$_MODULE["srtpljdz"]); $srbbbt = explode(",",$_MODULE["srbbbt"]); $srbbjg = explode(",",$_MODULE["srbbjg"]); $srxssl = explode(",",$_MODULE["srxssl"]); break;}if($_MODULE[huoqubaobei]!="4"){ $i=-1; foreach($items as $item){ $i++; $itemUrl = $uriManager->detailURI($item); $itemPicUrl = $item->getPicUrl(310); $itemTitle = $item->title; $itemPrice = $item->price; $itemsoldCount = $item->soldCount; echo'<div class="dptj1_coloum1"><div class="dptj1_coloum1_dri"><div class="jiantou"><img src="assets/images/youjiantou.png" / alt="谁帮忙看看 这个代码为什么不会循环" ></div><div class="content"><div class="wz"><a target="_blank" href="'.$itemUrl.'">'.$itemTitle.'</a></div><div class="price"><span class="price1">RMB:'.$itemPrice.'</span><span class="price2">¥ '.$szzkj[$i].'</span></div><div class="yishou">已售'.$itemsoldCount.'件</div></div></div><div class="dptj1_coloum1_pic"><a target="_blank" href="#"><img style="max-width:90%" src="'.$itemPicUrl.'" / alt="谁帮忙看看 这个代码为什么不会循环" ></a></div></div>'; }}else if($_MODULE[huoqubaobei]=="4"){ $num = count($srtpdz); for($i=0;$i<$num;$i++) { echo'<div class="dptj1_coloum1"><div class="dptj1_coloum1_dri"><div class="jiantou"><img src="assets/images/youjiantou.png" / alt="谁帮忙看看 这个代码为什么不会循环" ></div><div class="content"><div class="wz"><a target="_blank" href="'.$srtpljdz[$i].'">'.$srbbbt[$i].'</a></div><div class="price"><span class="price1">RMB:'.$srbbjg[$i].'</span><span class="price2">¥ '.$szzkj[$i].'</span></div><div class="yishou">已售'.$srxssl[$i].'件</div></div></div><div class="dptj1_coloum1_pic"><a target="_blank" href="'.$srtpljdz[$i].'"><img style="max-width:90%".$_MODULE["tpgd"].'px;" src="'.$srtpdz[$i].'" / alt="谁帮忙看看 这个代码为什么不会循环" ></a></div></div>'; }}?></div><?php}?>
for($i=0;$i<3;$i++)
for($i=0;$i<$num;$i++)
两个$i了
for($i=0;$i<3;$i++)
for($i=0;$i<$num;$i++)
两个$i了 刚改了 发现不一样啊 复制了好多好多
循环时把变量名注意一下,不要弄重了
if($_MODULE[huoqubaobei]!="4"){ $i=-1; foreach($items as $item){ $i++; $itemUrl = $uriManager->detailURI($item); $itemPicUrl = $item->getPicUrl(310); $itemTitle = $item->title; $itemPrice = $item->price; $itemsoldCount = $item->soldCount;