如何控制输出的数量 php
$sql="selectuchome_space.uid,uchome_spacefield.resideprovince,uchome_spacefield.uidfr...
$sql="select uchome_space.uid,uchome_spacefield.resideprovince ,uchome_spacefield.uid from uchome_space, uchome_spacefield where uchome_space.uid = uchome_spacefield.uid and resideprovince='广东' order by lastlogin desc ";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){
$img="data/0/".$aa=str_pad($row['uid'],3,"0",STR_PAD_LEFT)."_avatar_small.jpg";
$i=1;
foreach((array)$img as $ig){
if(file_exists($ig))
echo "<td class=iner ><img src='data/0/".$aa=str_pad($row['uid'],3,"0",STR_PAD_LEFT)."_avatar_small.jpg'><br/></td>";
$i++;}
if($i>=30)
break;
} 展开
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){
$img="data/0/".$aa=str_pad($row['uid'],3,"0",STR_PAD_LEFT)."_avatar_small.jpg";
$i=1;
foreach((array)$img as $ig){
if(file_exists($ig))
echo "<td class=iner ><img src='data/0/".$aa=str_pad($row['uid'],3,"0",STR_PAD_LEFT)."_avatar_small.jpg'><br/></td>";
$i++;}
if($i>=30)
break;
} 展开
1个回答
展开全部
order by 后加limit就ok
更多追问追答
追问
如果我在那里加limit 然后我的图片就显示不出来
追答
不会啊,sql 里加limit控制取得数据,while循环里针对读出来的内容做渲染。两个相互独立的。
试试:
$sql="select uchome_space.uid,uchome_spacefield.resideprovince ,uchome_spacefield.uid from uchome_space, uchome_spacefield where uchome_space.uid = uchome_spacefield.uid and resideprovince='广东' order by lastlogin desc limit 10 ";
看看?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询