php 嵌套循环 30
<?php$dosql->Execute("SELECT*FROM`#@__infoclass`WHEREparentid=5ANDcheckinfo=trueORDER...
<?php
$dosql->Execute("SELECT * FROM `#@__infoclass` WHERE parentid=5 AND checkinfo=true ORDER BY orderid ASC");
while($row=$dosql->GetArray()){
?>
<li id="page_Product?cid=<?php echo $row['id']; ?>">
<div class="pad">
<a href="#close" class="close"><span></span></a>
<div class="wrapper">
<ul class="bul">
<?php
$sql="SELECT * FROM `#@__infoimg` WHERE classid=".$row['id']." AND delstate='' AND checkinfo=true ORDER BY orderid ASC";
$dopage->GetPage($sql,9);
while($row2=$dosql->GetArray($row['id'])){
if($row2['picurl'] != '') $picurl=$row2['picurl'];
else $picurl = 'templates/default/images/nofoundpic.gif';
if($row2['linkurl']=='' and $cfg_isreurl!='Y') $gourl='productshow.php?cid='.$row2['classid'].'&id='.$row2['id'];
else if($cfg_isreurl=='Y') $gourl='productshow-'.$row2['classid'].'-'.$row2['id'].'-1.html';
else $gourl=$row2['linkurl'];
?>
<li><a href="<?php echo $gourl; ?>" class="img"><img src="<?php echo $picurl; ?>" /></a></li>
<?php
}
echo $dopage->GetList(); ?>
</ul>
</div>
</div>
</li>
<?php
}
?>
外层循环只执行了一次就没有了,请问是哪里出了问题? 展开
$dosql->Execute("SELECT * FROM `#@__infoclass` WHERE parentid=5 AND checkinfo=true ORDER BY orderid ASC");
while($row=$dosql->GetArray()){
?>
<li id="page_Product?cid=<?php echo $row['id']; ?>">
<div class="pad">
<a href="#close" class="close"><span></span></a>
<div class="wrapper">
<ul class="bul">
<?php
$sql="SELECT * FROM `#@__infoimg` WHERE classid=".$row['id']." AND delstate='' AND checkinfo=true ORDER BY orderid ASC";
$dopage->GetPage($sql,9);
while($row2=$dosql->GetArray($row['id'])){
if($row2['picurl'] != '') $picurl=$row2['picurl'];
else $picurl = 'templates/default/images/nofoundpic.gif';
if($row2['linkurl']=='' and $cfg_isreurl!='Y') $gourl='productshow.php?cid='.$row2['classid'].'&id='.$row2['id'];
else if($cfg_isreurl=='Y') $gourl='productshow-'.$row2['classid'].'-'.$row2['id'].'-1.html';
else $gourl=$row2['linkurl'];
?>
<li><a href="<?php echo $gourl; ?>" class="img"><img src="<?php echo $picurl; ?>" /></a></li>
<?php
}
echo $dopage->GetList(); ?>
</ul>
</div>
</div>
</li>
<?php
}
?>
外层循环只执行了一次就没有了,请问是哪里出了问题? 展开
2个回答
展开全部
首先是外面的循环用了$dosql->GetArray() 然后里面的循环又用了 $dosql->GetArray($row['id'])。$dosql是同一个吧,同一个就会在里面循环的时候把外面要循环的东西替换掉了。
追问
请问要怎么解决这个问题呢,请说详细点,谢谢!
追答
while($row=$dosql->GetArray()){
这个循环,你就得到一个放所有$row的数组。然后循环这个数组。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询