大家好,
我是PHP新手,请问要如何获取第一行第一列数据,该怎么写,有没有可用的方法或写好的类?

解决方案 »

  1.   

    你的查询条件是什么? 有哪些字段? 都没有说明。参考下面代码,自行修改SQL语句:$result=mysql_query("select * from table_name limit 1");
    $row=mysql_fetch_row($result);
    echo $row[0];
      

  2.   

    class mysql 

        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;  
        }      public function mysql_result_scalar($sql)
    {
           $result= $this->query("$sql limit 1");
           $row= $this->fetch_row($result);
           return $row[0];
    }}只是部分,如果需要可联系发完整版。