我试图找到一种方法,我可以默认显示在循环中,而其余部分被隐藏并将在调用时显示我现在拥有的一个无限循环我正在寻找解决方案或替代我的问题
for ($i=0 ; $i < $n_products; $i++) {
$PID = mysql_result($n_products,$i,'PID');
$prod_thumb = mysql_result($n_products,$i,'thumbnail');
$prod_des = mysql_result($n_products,$i, 'description');
$prod_price = mysql_result($n_products,$i, 'price');
$prod_name = mysql_result($n_products,$i, 'name');
$prod_img = mysql_result($n_products,$i,'img');
if ($i = 0){
echo"<div class=\"ortho_des\">
<div style=\"width:275px; height:215px; float:left;\">
<img width=\"275px\" height=\"215px\" src=\"$prod_img\"/>
</div>
<div>
<div style=\"float:left;\">Name: $prod_name</div><br/>
<div style=\"float:left;\">Color: $prod_name</div><br/>
<div style=\"float:left;\">Price: $prod_price $</div><br/>
</div>
<div class=\"clearFloat\"> </div>
<div>Description: $prod_des</div>
</div>";
}else{
echo"<div class=\"ortho_des\" style=\"display:none;\">
<div style=\"width:275px; height:215px; float:left;\">
<img width=\"275px\" height=\"215px\" src=\"$prod_img\"/>
</div>
<div>
<div style=\"float:left;\">Name: $prod_name</div><br/>
<div style=\"float:left;\">Color: $prod_name</div><br/>
<div style=\"float:left;\">Price: $prod_price $</div><br/>
</div>
<div class=\"clearFloat\"> </div>
<div>Description: $prod_des</div>
</div>";