MYSQL如何为查询数据的结果编上序号 while判断第几条

at 4年前  ca 记录笔记  pv 1301  by authorhu  

<?
$tsql=$empire->query("select (@i:=@i+1) i,tagid from {$dbtbpre}enewstagsdata , (SELECT @i:=0) as i where id='$navinfor[id]' and classid='$navinfor[classid]' ");
while($tr=$empire->fetch($tsql)){
	$tt=$empire->fetch1("select  * from {$dbtbpre}enewstags where tagid=".$tr['tagid']."  limit 1");
	$current='';
	if($tr['i']==1){
	$current=' current';
	}
	echo '<ul class="meishi-pic tab-item'. $current.'">';
	$ttn=$empire->query("select * from {$dbtbpre}ecms_news where title like '%".$tt['tagname']."%'  order by onclick desc limit 6");
	while($trn=$empire->fetch($ttn)){
	echo  '<li>
        <a href="'.$trn['titleurl'].'" target="_blank">
          <img class="lazy" data-original="'.$trn['titlepic'].'" alt="">
          <span class="info-m">'.$trn['title'].'</span>
          <b class="bg"></b>
        </a>
      </li>';
}
echo ' </ul>';
}
?>

版权声明

本文仅代表作者观点,未经许可,不得转载。

分享:

支付宝

微信