免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1511 | 回复: 0
打印 上一主题 下一主题

php分页显示的问题,请大家帮忙!非常非常感谢! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-13 13:10 |只看该作者 |倒序浏览
为什么,我用下面的这个例子取不出row[0]的值呀?

还有,我用odbc_field_name($rst,$q)这个方法也取不出它的field_name呢?
------------------------------------------------------------------

$page = $arr_request["page"];
$sql_type="exec p_comm_get_id_from_dict @main=\"理财博览\"";
$conn = odbc_connect($odbc_name, $odbc_uid,$odbc_pwd) or die ("连接ODBC失败";
$rst=odbc_exec($conn,$sql_type);
$type=odbc_result($rst,1);
odbc_free_result($rst);
//$type=204;



$sql = "select id,title,time from t_grlc_news where (datediff(d,time,getdate())<30) and type=$type order by time DESC";
$record_num = "select count(*) as record_number from t_grlc_news where datediff(d,time,getdate())<30 and type=$type";



//定义每页记录数
$pagesize =16;



//连接数据库求出总页数
//$conn = odbc_connect($odbc_name, $odbc_uid,$odbc_pwd) or die ("连接ODBC失败";
$rst = odbc_exec($conn,$record_num) or die("查询出错"; //执行取得记录总数SQL语句
$record_count_num = odbc_result($rst,"record_number"; //取得记录总数,在这里也可以用$recordcount = odbc_result($rst,"record_number";
odbc_free_result($rst); //释放资源



$page_count_num = ceil($record_count_num/$pagesize);
//控制接收页数值的正确性
if($page>;$page_count_num)
{
   $page = $page_count_num;
}elseif($page<1)
{
$page = 1;
}



//以下输出内容
$rst = odbc_exec($conn,$sql) or die("$sql查询出错"; //执行取得数据SQL语句
$fieldcount = odbc_num_fields($rst); //取得字段总数
print "<table width=90% border="0" cellspacing="0" cellpadding="4" align=center>;";
   $rowi = ($page-1)*$pagesize+1;
   for($i=0;$i<$pagesize;$i++){
print "<tr>;";
        if($rowi<=$record_count_num){
odbc_fetch_into($rst,$rowi,&$row);
if($i==0) print "<center>;<img src=\"../../images/grlc/e1.gif\" width=\"526\" height=\"36\">;<br>;<hr width=100% color=#003399>;";
         for($q=1;$q<=$fieldcount;$q++)
{
if(odbc_field_name($rst,$q)=="id"
{
$news_id=$row[0];
}
if (odbc_field_name($rst,$q)=="title"
{
print "<td width=80%>; &nbsp<img src=\"../../images/grlc/star.gif\" width=\"8\" height=\"8\">;  <a href="lcbl_detail.php?id=$news_id" target=_blank>;" . $row[1] . "</td>;";
              }
            if(odbc_field_name($rst,$q)=="time"
            {
                  print "<td width=20%>;" .substr($row[2],0,10) . "</td>;";
              }
            }
         $rowi = $rowi+1;
      }
      print "</tr>;";
   }



   print "</table>;";
   odbc_free_result($rst); //释放资源
  odbc_close($conn); //关闭连接并释放资源



if ($page_count_num>;1)
{
print "<form method=post action=\"$PHP_SELF?page=$pages\">;";
print "<table border=0 cellspacing=\"0\" cellpadding=\"0\">;<tr bgcolor="#ffffff">;";
if($page>;1)
{ //页码比0大,表示有数据
print "<td width=80>;<a href=\"$PHP_SELF?page=1\">;首页</td>;";
  }
else{
print "<td width=80>;首页</td>;";
  }
if($page>;1){
  $pages = $page - 1;
  print "<td width=80>;<a href=\"$PHP_SELF?page=$pages$sql_condition\">;上页</td>;";
  }
  else{
   print "<td width=80>;上页</td>;";
     }
  if($page<$page_count_num){
$pages = $page + 1;
print "<td width=80>;<a href=\"$PHP_SELF?page=$pages$sql_condition\">;下页</td>;";}
  else{
   print "<td width=80>;下页</td>;";
  }
  if($page<$page_count_num){
print "<td width=80>;<a href=\"$PHP_SELF?page=$page_count_num\">;尾页</td>;";
}
else{
print "<td width=80>;尾页</td>;";
    }
  print "<td width=80>;页码($page/$page_count_num)</td>;";
  print "<td width=80 align = center>;<input type=input size=3 name=page>; <input type=submit value=go name=go>;</td>;";
  print "</tr>;";
print "</table>;";
print "</form>;";
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP