帝国CMS按照26个字母顺序循环调用信息的方法

帝国CMS按照26个字母顺序循环调用信息,也就是a/b/c/e/f/g…的顺序依次调用。

<?

$pd_record=explode(
“,”,
‘A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z’);


for($i=
0;$i<count($pd_record);$i++)

{

?>

<div
class=
“letter_items”>

<dt id=
“<?=strtolower($pd_record[$i])?>”><?=$pd_record[$i]?></dt>

<div
class=
“letter_item_con”>

<?php

$newbook=$empire->query(
“select id,name from {$dbtbpre}extend_linkage where zm= ‘”.$pd_record[$i].
“‘ and parentid<>1 and id<>1 order by id desc”);


while($r=$empire->fetch($newbook)) {

$num=$empire->gettotal(
“select count(*) as total from {$dbtbpre}ecms_weixin where city=’$r[id]'”);

?>

<dd><a href=
“/citylist/?city=<?=$r[‘id’]?>&t=personal”><?=str_replace(
‘市’,
,esub($r[
‘name’],
10))?>(<span><?=$num?></span>)</a></dd>

<?}?>

</div>

</div>

<?

}

?>

 

主要看这段for按字母顺序循环调用的方法:

<?

$pd_record=explode(
“,”,
‘A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z’);


for($i=
0;$i<count($pd_record);$i++)

{

?>

 

然后在看这段,内循环查询字段等于外循环字母的信息:

$newbook=$empire->query(
“select id,name from {$dbtbpre}extend_linkage where zm= ‘”.$pd_record[$i].
“‘ and parentid<>1 and id<>1 order by id desc”);

 

精准像素这样分解,你一看就懂了吧。