免费注册 查看新帖 |

Chinaunix

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

请大家看看我的代码有问题没? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-11 17:56 |只看该作者 |倒序浏览
10可用积分
  1. //查询指定行的数据
  2. public function SearchPage($from,$to,$index,$length)
  3. {
  4.   //$resultArray = array();
  5.   $resultArray[] = array("污染物","采样值","时间","系统","检测点信息");
  6.   $this->dbCon->query("select polid,rtd,time,st,mn from samplindb where time between '$from' and '$to' limit $index,$length;");
  7.   while($result=$this->dbCon->fetch_row())
  8.   {
  9.    $resultArray[] = $result;
  10.   }
  11.   return $resultArray;
  12. }
复制代码
好像从数据库里取不到数据。

[ 本帖最后由 也是菜鸟 于 2009-8-11 17:59 编辑 ]

table.JPG (23.42 KB, 下载次数: 32)

table.JPG

最佳答案

查看完整内容

有错误信息吗?SQL直接在数据库上执行能取到数吗?

论坛徽章:
0
2 [报告]
发表于 2009-08-11 17:56 |只看该作者
有错误信息吗?

SQL直接在数据库上执行能取到数吗?

论坛徽章:
0
3 [报告]
发表于 2009-08-11 19:53 |只看该作者
$rs =$this->dbCon->query("select polid,rtd,time,st,mn from samplindb where time between '$from' and '$to' limit $index,$length;");
while($result=$this->dbCon->fetch_row($rs))
  {
   $resultArray[] = $result;
  }

试下

论坛徽章:
0
4 [报告]
发表于 2009-08-12 10:16 |只看该作者
试了试,用命令行能查到数据,问题出在2维数组的使用上。
我把   $resultArray[] = $result;
改为其他赋值语句就好了。原来这语句是别人写的,我也不大明白其作用。认真想了下,觉得有问题,就改了。

pxllonga ,你说的dbCon->fetch_row($rs)) 。dbCon是一个类,里边的query按设定是没返回值的,fetch_row()也是没有参数的。 呵呵。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP