Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 基于每周数据的图表_Php_Mysql_Highcharts - Fatal编程技术网

Php 基于每周数据的图表

Php 基于每周数据的图表,php,mysql,highcharts,Php,Mysql,Highcharts,各位程序员,晚安。我很难使用PHP、MySQL和Highcharts库来整理每周记录的图表 我有连接和断开的记录,其中以2017-03-30 16:43:04的格式保存,但在以行为单位的图表中,我需要在7天内显示此信息 例如,从今天开始的一周:横坐标轴将包含7个值03/04、04/04、04/04、06/04、07/04、08/04和09/04,纵坐标轴将具有表示一定连接量或断开量的整数值 我不知道如何在后端生成这些数据,尤其是SQL查询 表列: id |用户名|事件|日期 其中,id是事件id

各位程序员,晚安。我很难使用PHP、MySQL和Highcharts库来整理每周记录的图表

我有连接和断开的记录,其中以2017-03-30 16:43:04的格式保存,但在以行为单位的图表中,我需要在7天内显示此信息

例如,从今天开始的一周:横坐标轴将包含7个值03/04、04/04、04/04、06/04、07/04、08/04和09/04,纵坐标轴将具有表示一定连接量或断开量的整数值

我不知道如何在后端生成这些数据,尤其是SQL查询

表列:

id |用户名|事件|日期

其中,id事件id,用户名用户名事件可以采用连接或断开连接值,日期是2017-03-30 16:43:04格式的日期

图表示例:

我做的丑陋的方式:

以DD/MM格式获取6天前+今天:

$date['timestamp']=数组(
“0”=>this->db->select(“日期”\u添加(CURDATE(),INTERVAL-6-工作日(CURDATE())DAY)作为dateX”)->get()->row()->dateX,
“1”=>this->db->select(“DATE\u添加(CURDATE(),INTERVAL-5-WEEKDAY(CURDATE())DAY)作为dateX”)->get()->row()->dateX,
“2'=>this->db->选择(“日期添加(CURDATE(),INTERVAL-4-工作日(CURDATE())DAY)作为dateX”)->get()->row()->dateX,
“3”=>this->db->select(“日期添加(CURDATE(),INTERVAL-3-工作日(CURDATE())DAY)作为dateX”)->get()->row()->dateX,
'4'=>this->db->select(“日期添加(CURDATE(),INTERVAL-2-WEEKDAY(CURDATE())DAY)为dateX”)->get()->row()->dateX,
“5'=>this->db->select(“日期”添加(CURDATE(),INTERVAL-1-工作日(CURDATE())DAY)作为dateX”)->get()->row()->dateX,
“6'=>this->db->select(“日期”\u添加(CURDATE(),INTERVAL+0-工作日(CURDATE())DAY)作为dateX”)->get()->row()->dateX
);

根据上述日期获取连接和断开连接:

$date['series']=数组(
“con”=>数组(
“0”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 6 DAY')->get()->row()->dateX,
“1”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 5 DAY')->get()->row()->dateX, “2”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 4 DAY')->get()->row()->dateX, “3”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client','Client_name)->where('date(cl_date)=CURDATE INTERVAL 3 DAY')->get()->row()->dateX, “4”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client','Client_name)->where('date(cl_date)=CURDATE INTERVAL 2 DAY')->get()->row()->dateX, “5”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 1 DAY')->get()->row()->dateX, “6”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','conexão')->where('cl_Client','Client_name)->where('date(cl_date)=CURDATE INTERVAL 0 DAY')->get()->row()->dateX
), 'dis'=>数组( “0”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 6 DAY')->get()->row()->dateX,
“1”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 5 DAY')->get()->row()->dateX, “2”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 4 DAY')->get()->row()->dateX, “3”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 3 DAY')->get()->row()->dateX, “4”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client','Client_name)->where('date(cl_date)=CURDATE INTERVAL 2 DAY')->get()->row()->dateX, “5”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client',$Client_name)->where('date(cl_date)=CURDATE INTERVAL 1 DAY')->get()->row()->dateX, “6”=>this->db->select('COUNT(id_ConnectionLog)AS dateX')->from('connection_log')->where('cl_Event','desconexão')->where('cl_Client','Client_name)->where('date(cl_date)=CURDATE INTERVAL 0 DAY')->get()->row()->dateX
)
);

类似于
从表组中按周(日期列)选择计数(*)、周(日期列)
,可能吗?然后根据每个数据构建折线图point@chris85我解决了这个问题,但方法很难看。我将编辑我的q