这是查询的代码
$array1[0]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='01'");
     $array1[1]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='02'");
     $array1[2]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='03'");
     $array1[3]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='04'");
     $array1[4]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='05'");
     $array1[5]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='06'");
     $array1[6]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='07'");
     $array1[7]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='08'");
     $array1[8]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='09'");
     $array1[9]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='10'");
     $array1[10]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='11'");
     $array1[11]= $this->db->query('select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"]." and year(create_time)='2012' and month(create_time)='12'");
    

$result = array();


foreach ( $array1 as $v ) {
$result[] = $v->row_array();

}
                    
                        print_r($result);
exit();
$_SESSION =$v;

结果是:
Array
(
    [0] => Array
        (
            [count(customer_id)] => 4
        )    [1] => Array
        (
            [count(customer_id)] => 1
        )    [2] => Array
        (
            [count(customer_id)] => 1
        )    [3] => Array
        (
            [count(customer_id)] => 2
        )    [4] => Array
        (
            [count(customer_id)] => 2
        )    [5] => Array
        (
            [count(customer_id)] => 1
        )    [6] => Array
        (
            [count(customer_id)] => 1
        )    [7] => Array
        (
            [count(customer_id)] => 3
        )    [8] => Array
        (
            [count(customer_id)] => 2
        )    [9] => Array
        (
            [count(customer_id)] => 1
        )    [10] => Array
        (
            [count(customer_id)] => 3
        )    [11] => Array
        (
            [count(customer_id)] => 2
        ))


print_r($result);
exit();
$_SESSION =$v;

但是我作图的代码是
$dataArray = array('4','1','1','2','2','1','1','3','2','1','3','2');
$lableArray  = array('January','February','March','April','May','June','July','August','September','October','November','December');
我用了 $dataArray = $_SESSION;
可是不行方法只识别  array('4','1','1','2','2','1','1','3','2','1','3','2'); 这样的数组,我只需要把$result数组变为可识别的数组就可以了,但就是想不出来,求救啊。

解决方案 »

  1.   

    SQL串写作
    $sql = 'select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"].' and year(create_time)='2012' group by  month(create_time) order by month(create_time)';$this->db->query($sql); 后将取出全部12个月的数据你看一下取出的数据就知道接下来该怎么做了
      

  2.   

    我试过了你的SQL文出来的结果确实是一个数组,比我的好,但是我把他放在array1里面
     $sql = 'select count(customer_id) '.$str2.' where bl_salesman_id='.$_POST["EmployeeId"].' and year(create_time)="2012" group by month(create_time) order by month(create_time)';
          $array1[]=$this->db->query($sql);print_r($array1);出来的结果还是一个结果集,我把他遍历一遍
    $result = array();

    foreach ( $array1 as $v ) {
    $result[] = $v->row_array();

    }


    print_r($result);

    出来的结果就成了
    Array
    (
        [0] => Array
            (
                [count(customer_id)] => 4
            ))
    我的意思是把结果变成
    array('4','1','1','2','2','1','1','3','2','1','3','2');
    这样的,我就好引用了。现在就是不会把查出来的数据转换成我要的数组形式。还是要谢谢你。
      

  3.   

    现在想出来了原来是我forech有问题,感谢你的SQL最后用的是你的这种方法。
      

  4.   

    现在想出来了原来是我forech有问题,感谢你的SQL最后用的是你的这种方法。