轮播图片代码是这样的一个形式:
<div style="display:" id="der0"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/1.jpg" width="800" height="560" border="0" /></a></div>
<div style="display:none" id="der1"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/2.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der2"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/3.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der3"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/4.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der4"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/5.jpg" width="800" height="560" border="0" /></a></div>因为第一个display和以后的都不一样,那么第一个应该不参与循环吧,想用while($row = $result->fetch_row()){ *循环代码 }这样的方式循环,该怎么办呢……有啥能跳一个再循环的方法呢
<div style="display:" id="der0"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/1.jpg" width="800" height="560" border="0" /></a></div>
<div style="display:none" id="der1"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/2.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der2"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/3.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der3"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/4.jpg" width="800" height="560" border="0" /></a></div><div style="display:none" id="der4"><a href="javascript:history.back()" style="cursor:pointer;" target="_parent"><img src="images/5.jpg" width="800" height="560" border="0" /></a></div>因为第一个display和以后的都不一样,那么第一个应该不参与循环吧,想用while($row = $result->fetch_row()){ *循环代码 }这样的方式循环,该怎么办呢……有啥能跳一个再循环的方法呢
最直接的方法 在while循环内做个判断就可以了
$i=0;
while(con)
{
if($i==0)
//不显示的样式
else
//显示的样式
$i++;
}
$i=0;
while($rs=$db->fetch_array($query))
{
$display=$i==0?"block":"none";
echo "<div id=der{$i} style='display:$display'></div>";
$i++;
}