着与你的 db 类的 query 写法有关
没看到,不好说

解决方案 »

  1.   

    public function query($sql) {
    if ($sql == "") {
    $this->show_error("SQL语句错误:", "SQL查询语句为空");
    }
    $this->sql = $sql; $result = mysql_query($this->sql, $this->conn); if (!$result) {
    //调试中使用,sql语句出错时会自动打印出来
    if ($this->show_error) {
    $this->show_error("错误SQL语句:", $this->sql);
    }
    } else {
    $this->result = $result;
    }
    return $this->result;
    }这是query的写法;  难道与return有关系? 这个函数应该如何修正,不用return要写什么;
      

  2.   

    看起来你用的好像是mysqli类,但是这个类的query返回是mysqli_result类,mysqli_result的fetch_array()不是这么用的。
    如果是mysqli类,应该是这样吧$query=$db->query("select * from `p_newsclass` where `f_id`='0' "); //f_id=0 主分类;
    while($row=$query->fetch_array()){ 
    echo $row[id].$row[name];
    $sonquery=$db->query("select * from `p_newsclass` where `f_id`='$row[id]'");
    while($son=$sonquery->fetch_array()){
    echo $son[id].$son[name];
      

  3.   


    $query=$db->query("select * from `p_newsclass` where `f_id`='0' "); //f_id=0 主分类;
    $result = array();
    while($row=$db->fetch_array($query)){
        $result[] = $row;
    }print_r($result);
    把数组打印出来看看有什么。
      

  4.   

    问题就出在 $this->result = $result; 上
    内层的查询结果呢把外层的覆盖掉了