这是查询的代码
$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数组变为可识别的数组就可以了,但就是想不出来,求救啊。
$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数组变为可识别的数组就可以了,但就是想不出来,求救啊。
解决方案 »
- 与JAVA程序通信
- php上传图片关于图片路径问题
- Fatal error: Unsupported operand types
- php初学者求救
- php and apache
- 可否通过php验证域中的用户?
- 怎样把网页上的表格内容导入到excel中,表格title有两层甚至三层,有例子请参考
- 各位大蝦好呵! 先問一下, php 中怎樣用imap函數將一封新郵件標識成已讀 ?還有imap_setflag_full具體怎樣用。。?
- select显示
- 初学php,请问文章(不是页面)对应的页面的哪个?预览文章时总是跳到首页
- mysql字段长度
- Smarty error: unable to read resource的解决办法
$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个月的数据你看一下取出的数据就知道接下来该怎么做了
$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');
这样的,我就好引用了。现在就是不会把查出来的数据转换成我要的数组形式。还是要谢谢你。