<?php
$exe="select count(*) as count from t_gongqiu where info=0";
$result1=mysql_query($exe);
$rss=mysql_fetch_array($result1);
$ROW=$rss['count']/2;
$exec="select * from t_gongqiu where info=0 order by Id desc limit 5";
$result=mysql_query($exec);//请求结果
$tb="<table>";
while($rs=mysql_fetch_array($result))
{
$id="$rs[Id]";
$rs['title']=substr($rs['title'],0,30);
if($rs["info"]==0)
{
$info1='[供应]';
}
else
{
$info1='[求购]';
}
$tb.="<tr><td>$id</td><td>$rs['title']</td><td>$info1</td></tr>";
}
$tb.="</table>";
echo $tb;
?>
这样,循环一次就得到分三列的行了.
$rs['title']=substr($rs['title'],0,30);
$rs['title']=substr($rs['title'],0,30);
这个就不要两次那么多吧?
$exe="select count(*) as count from t_gongqiu where info=0";
$result1=mysql_query($exe);
$rss=mysql_fetch_array($result1);
$ROW=$rss['count']/2;
$exec="select * from t_gongqiu where info=0 order by Id desc limit 5";
$result=mysql_query($exec);//请求结果
$tb="<table>";
while($rs=mysql_fetch_array($result))
{
$id="$rs[Id]";
$rs['title']=substr($rs['title'],0,30);
if($rs["info"]==0)
{
$info1='[供应]';
}
else
{
$info1='[求购]';
}
$tb.="<tr><td>$id</td><td>$rs['title']</td><td>$info1</td></tr>";
}
$tb.="</table>";
echo $tb;
?>
这样,循环一次就得到分三列的行了.
$rs['title']=substr($rs['title'],0,30);
$rs['title']=substr($rs['title'],0,30);
这个就不要两次那么多吧?
解决方案 »
- 新手求教uestudio编写的html如何改成php格式
- php 正则匹配 提取 图片地址
- 如何将数组用自定义函数排序后重新生成一个新数组?
- $count为什么输出为0!!指教
- ajax無刷新留言板問題
- PHP正则去掉重复字符,得不到我要的结果?
- 编码转换,请问将一个每繁体版网站转成utf8的简体网站如果操作?
- session的问题,以开始就卡住了····
- 能否把java script的变量传给php的变量,谢谢,紧急
- php CURL 采集 dwr 的 搜索结果
- 高手们,请问一个每周显示信息的难题
- phpedit求救,自动安装完后编辑了一php文件,然后运行,提示错误是文件没有保存,但是文件明明是保存了的.
$exe="select count(*) as count from t_gongqiu where info=0";
$result1=mysql_query($exe);
$rss=mysql_fetch_array($result1);
$ROW=$rss['count']/2;
$exec="select * from t_gongqiu where info=0 order by Id desc limit 5";
$result=mysql_query($exec);//请求结果
$i=0;
while($rs=mysql_fetch_array($result))
{
$id="$rs[Id]";
$rs['title']=substr($rs['title'],0,30);
if($rs["info"]==0)
{
$info1='[供应]';
}
else
{
$info1='[求购]';
}
echo "$rs['title'] ";
$i++;
if($i==3){
$i=0;
echo "<BR>-------------------------------------------<BR>";
}?>
是这样子吗?