设置一个变量,显示一条加1,显示7条后就不再显示了

解决方案 »

  1.   


    $str="select tgbs as bs,tgbt as bt from tgsp where status = 1 and getdate() between isnull(fbqsrq,getdate()) and isnull(fbjzrq,getdate()) order by case when  gmcs is null then 999999 else gmcs end desc";  
    $ph_query = tep_db_query($str);  <?  
    $i = 0;//增加一个自增字段
    $num = 7;//需要的记录数
    while($paih = tep_db_fetch_array($ph_query)){ 
    if($i == $num){  //如果记录数与已循环次数相等,则跳出循环
       break;

    ?>  
    <li>·  <? echo '  <a   class="L100"  title="'.$paih['bt'].'" href="'.tep_href_link('tuangoushow.php','id='.$paih['bs']) .'" target=_parent>  <script>document.write("'.$paih['bt'].'".length>9?"'.$paih['bt'].'".substring(0,9)+"...":"'.$paih['bt'].'");  </script>  </a> ' ?>    </li>   
    <?php  
    $i++;
    }  
    ?>