侯体宗的博客
  • 首页
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

php实现按天数、星期、月份查询的搜索框

php  /  管理员 发布于 7年前   124

本文实例为大家分享了php实现按天数、星期、月份查询的搜索框,搜索时候展示数据的统计图,主要展示图形的效果,供大家参考,具体内容如下

1.ajax.php

date('Y-m-d',$i).'|'.date('Y-m-d',$i+3600*24*6), 'val'=>date('Y-m-d',$i).'~'.date('Y-m-d',$i+3600*24*6));  }  return $week_arr;}

2.datehelper.php

'2010','2011'=>'2011','2012'=>'2012','2013'=>'2013','2014'=>'2014','2015'=>'2015','2016'=>'2016','2017'=>'2017','2018'=>'2018','2019'=>'2019','2020'=>'2020');  return $year_arr;} /** * 获得系统月份数组 *  * @return array */function getSystemMonthArr(){     $month_arr = array('1'=>'01','2'=>'02','3'=>'03','4'=>'04','5'=>'05','6'=>'06','7'=>'07','8'=>'08','9'=>'09','10'=>'10','11'=>'11','12'=>'12');  return $month_arr;} /** * 获得系统周数组 *  * @return string[] */function getSystemWeekArr(){  $week_arr = array('1'=>'周一','2'=>'周二','3'=>'周三','4'=>'周四','5'=>'周五','6'=>'周六','7'=>'周日');  return $week_arr;} /** * 获取某月的最后一天 *  * @param int $year * @param int $month * @return number */function getMonthLastDay($year, $month){     $t = mktime(0, 0, 0, $month + 1, 1, $year);  $t = $t - 60 * 60 * 24;  return $t;} /** * 获得系统某月的周数组,第一周不足的需要补足 *  * @param int $current_year * @param int $current_month * @return string[][] */function getMonthWeekArr($current_year, $current_month){     //该月第一天  $firstday = strtotime($current_year.'-'.$current_month.'-01');  //该月的第一周有几天  $firstweekday = (7 - date('N',$firstday) +1);  //计算该月第一个周一的时间  $starttime = $firstday-3600*24*(7-$firstweekday);  //该月的最后一天  $lastday = strtotime($current_year.'-'.$current_month.'-01'." +1 month -1 day");  //该月的最后一周有几天  $lastweekday = date('N',$lastday);  //该月的最后一个周末的时间  $endtime = $lastday-3600*24*($lastweekday%7);  $step = 3600*24*7;//步长值  $week_arr = array();  for ($i=$starttime; $i<$endtime; $i= $i+3600*24*7){    $week_arr[] = array('key'=>date('Y-m-d',$i).'|'.date('Y-m-d',$i+3600*24*6), 'val'=>date('Y-m-d',$i).'~'.date('Y-m-d',$i+3600*24*6));  }  return $week_arr;}    /**   * 处理搜索时间   */ function dealwithSearchTime($search_arr=''){    //初始化时间    //天    if(!isset($search_arr['search_time'])){      $search_arr['search_time'] = date('Y-m-d', time()- 86400);    }     $search_arr['day']['search_time'] = strtotime($search_arr['search_time']);//搜索的时间    //周    if(!isset($search_arr['searchweek_year'])){      $search_arr['searchweek_year'] = date('Y', time());    }    if(!isset($search_arr['searchweek_month'])){      $search_arr['searchweek_month'] = date('m', time());    }    if(!isset($search_arr['searchweek_week'])){      $search_arr['searchweek_week'] = implode('|', getWeek_SdateAndEdate(time()));    }      $weekcurrent_year = $search_arr['searchweek_year'];    $weekcurrent_month = $search_arr['searchweek_month'];    $weekcurrent_week = $search_arr['searchweek_week'];    $search_arr['week']['current_year'] = $weekcurrent_year;    $search_arr['week']['current_month'] = $weekcurrent_month;    $search_arr['week']['current_week'] = $weekcurrent_week;     //月    if(!isset($search_arr['searchmonth_year'])){      $search_arr['searchmonth_year'] = date('Y', time());    }    if(!isset($search_arr['searchmonth_month'])){      $search_arr['searchmonth_month'] = date('m', time());    }    $monthcurrent_year = $search_arr['searchmonth_year'];    $monthcurrent_month = $search_arr['searchmonth_month'];    $search_arr['month']['current_year'] = $monthcurrent_year;    $search_arr['month']['current_month'] = $monthcurrent_month;    return $search_arr;  }   /**   * 获取本周的开始时间和结束时间   *    * @param int $current_time   * @return string   */  function getWeek_SdateAndEdate($current_time){         $current_time = strtotime(date('Y-m-d',$current_time));    $return_arr['sdate'] = date('Y-m-d', $current_time-86400*(date('N',$current_time) - 1));    $return_arr['edate'] = date('Y-m-d', $current_time+86400*(7- date('N',$current_time)));         return $return_arr;  }  /**   * 查询每月的周数组   */ function getweekofmonth(){    $year = $_GET['y'];    $month = $_GET['m'];    $week_arr = getMonthWeekArr($year, $month);    echo json_encode($week_arr);    die;  }

3.statistics.php

"{$stat_arr['title']}",'x'=>-20):'';  //子标题如果为字符串则使用默认样式  is_string($stat_arr['subtitle'])?$stat_arr['subtitle'] = array('text'=>"{$stat_arr['subtitle']}",'x'=>-20):'';  //Y轴如果为字符串则使用默认样式  if(is_string($stat_arr['yAxis'])){    $text = $stat_arr['yAxis'];    unset($stat_arr['yAxis']);    $stat_arr['yAxis']['title']['text'] = $text;  }  return json_encode($stat_arr);} /** * 获得Column2D统计图数据 *  * @param array $stat_arr * @return string */function getStatData_Column2D($stat_arr){     //图表区、图形区和通用图表配置选项  $stat_arr['chart']['type'] = 'column';  //去除版权信息  $stat_arr['credits']['enabled'] = false;  //导出功能选项  $stat_arr['exporting']['enabled'] = false;  //标题如果为字符串则使用默认样式  is_string($stat_arr['title'])?$stat_arr['title'] = array('text'=>"{$stat_arr['title']}",'x'=>-20):'';  //子标题如果为字符串则使用默认样式  is_string($stat_arr['subtitle'])?$stat_arr['subtitle'] = array('text'=>"{$stat_arr['subtitle']}",'x'=>-20):'';  //Y轴如果为字符串则使用默认样式  if(is_string($stat_arr['yAxis'])){    $text = $stat_arr['yAxis'];    unset($stat_arr['yAxis']);    $stat_arr['yAxis']['title']['text'] = $text;  }  //柱形的颜色数组  $color = array('#7a96a4','#cba952','#667b16','#a26642','#349898','#c04f51','#5c315e','#445a2b','#adae50','#14638a','#b56367','#a399bb','#070dfa','#47ff07','#f809b7');     foreach ($stat_arr['series'] as $series_k=>$series_v){    foreach ($series_v['data'] as $data_k=>$data_v){      $data_v['color'] = $color[$data_k];      $series_v['data'][$data_k] = $data_v;    }    $stat_arr['series'][$series_k]['data'] = $series_v['data'];  }  //print_r($stat_arr); die;  return json_encode($stat_arr);} /** * 获得Basicbar统计图数据 *  * @param array $stat_arr * @return string */function getStatData_Basicbar($stat_arr){     //图表区、图形区和通用图表配置选项  $stat_arr['chart']['type'] = 'bar';  //去除版权信息  $stat_arr['credits']['enabled'] = false;  //导出功能选项  $stat_arr['exporting']['enabled'] = false;  //显示datalabel  $stat_arr['plotOptions']['bar']['dataLabels']['enabled'] = true;  //标题如果为字符串则使用默认样式  is_string($stat_arr['title'])?$stat_arr['title'] = array('text'=>"{$stat_arr['title']}",'x'=>-20):'';  //子标题如果为字符串则使用默认样式  is_string($stat_arr['subtitle'])?$stat_arr['subtitle'] = array('text'=>"{$stat_arr['subtitle']}",'x'=>-20):'';  //Y轴如果为字符串则使用默认样式  if(is_string($stat_arr['yAxis'])){    $text = $stat_arr['yAxis'];    unset($stat_arr['yAxis']);    $stat_arr['yAxis']['title']['text'] = $text;  }  //柱形的颜色数组  $color = array('#7a96a4','#cba952','#667b16','#a26642','#349898','#c04f51','#5c315e','#445a2b','#adae50','#14638a','#b56367','#a399bb','#070dfa','#47ff07','#f809b7');     foreach ($stat_arr['series'] as $series_k=>$series_v){    foreach ($series_v['data'] as $data_k=>$data_v){      if (!$data_v['color']){        $data_v['color'] = $color[$data_k%15];      }      $series_v['data'][$data_k] = $data_v;    }    $stat_arr['series'][$series_k]['data'] = $series_v['data'];  }  //print_r($stat_arr); die;  return json_encode($stat_arr);} /** * 计算环比 *  * @param array $updata * @param array $currentdata * @return string */function getHb($updata, $currentdata){     if($updata != 0){    $mtomrate = round(($currentdata - $updata)/$updata*100, 2).'%';  } else {    $mtomrate = '-';  }  return $mtomrate; } /** * 计算同比 *  * @param array $updata * @param array $currentdata * @return string */function getTb($updata, $currentdata){     if($updata != 0){    $ytoyrate = round(($currentdata - $updata)/$updata*100, 2).'%';  } else {    $ytoyrate = '-';  }  return $ytoyrate; } /** * 地图统计图 *  * @param array $stat_arr * @return string */function getStatData_Map($stat_arr){     //$color_arr = array('#f63a3a','#ff5858','#ff9191','#ffc3c3','#ffd5d5');  $color_arr = array('#fd0b07','#ff9191','#f7ba17','#fef406','#25aae2');  $stat_arrnew = array();  foreach ($stat_arr as $k=>$v){    $stat_arrnew[] = array('cha'=>$v['cha'],'name'=>$v['name'],'des'=>$v['des'],'color'=>$color_arr[$v['level']]);  }  return json_encode($stat_arrnew);} /** * 获得饼形图数据 *  * @param array $data * @return string */function getStatData_Pie($data){     $stat_arr['chart']['type'] = 'pie';  $stat_arr['credits']['enabled'] = false;  $stat_arr['title']['text'] = $data['title'];  $stat_arr['tooltip']['pointFormat'] = '{series.name}: {point.y}';  $stat_arr['plotOptions']['pie'] = array(    'allowPointSelect'=>true,    'cursor'=>'pointer',    'dataLabels'=>array(      'enabled'=>$data['label_show'],      'color'=>'#000000',      'connectorColor'=>'#000000',      'format'=>'{point.name}: {point.percentage:.1f} %'    )  );  $stat_arr['series'][0]['name'] = $data['name'];  $stat_arr['series'][0]['data'] = array();  foreach ($data['series'] as $k=>$v){    $stat_arr['series'][0]['data'][] = array($v['p_name'],$v['allnum']);  }  //exit(json_encode($stat_arr));  return json_encode($stat_arr);}

4.theline.php  

Echarts      

5.time_deal.php

'2010','2011'=>'2011','2012'=>'2012','2013'=>'2013','2014'=>'2014','2015'=>'2015','2016'=>'2016','2017'=>'2017','2018'=>'2018','2019'=>'2019','2020'=>'2020');  return $year_arr;} /** * 获得系统月份数组 *  * @return array */function getSystemMonthArr(){     $month_arr = array('1'=>'01','2'=>'02','3'=>'03','4'=>'04','5'=>'05','6'=>'06','7'=>'07','8'=>'08','9'=>'09','10'=>'10','11'=>'11','12'=>'12');  return $month_arr;}   /**   * 处理搜索时间   */  public function dealwithSearchTime($search_arr){    //初始化时间    //天    if(!$search_arr['search_time']){      $search_arr['search_time'] = date('Y-m-d', time()- 86400);    }    $search_arr['day']['search_time'] = strtotime($search_arr['search_time']);//搜索的时间       //周    if(!$search_arr['searchweek_year']){      $search_arr['searchweek_year'] = date('Y', time());    }    if(!$search_arr['searchweek_month']){      $search_arr['searchweek_month'] = date('m', time());    }    if(!$search_arr['searchweek_week']){      $search_arr['searchweek_week'] = implode('|', getWeek_SdateAndEdate(time()));    }    $weekcurrent_year = $search_arr['searchweek_year'];    $weekcurrent_month = $search_arr['searchweek_month'];    $weekcurrent_week = $search_arr['searchweek_week'];    $search_arr['week']['current_year'] = $weekcurrent_year;    $search_arr['week']['current_month'] = $weekcurrent_month;    $search_arr['week']['current_week'] = $weekcurrent_week;       //月    if(!$search_arr['searchmonth_year']){      $search_arr['searchmonth_year'] = date('Y', time());    }    if(!$search_arr['searchmonth_month']){      $search_arr['searchmonth_month'] = date('m', time());    }    $monthcurrent_year = $search_arr['searchmonth_year'];    $monthcurrent_month = $search_arr['searchmonth_month'];    $search_arr['month']['current_year'] = $monthcurrent_year;    $search_arr['month']['current_month'] = $monthcurrent_month;    return $search_arr;  }

以上就是本文的全部内容,希望对大家的学习有所帮助。

您可能感兴趣的文章:

  • PHP实现今天是星期几的几种写法
  • PHP获取指定日期是星期几的实现方法
  • PHP获取星期几的常用方法小结
  • PHP获取日期对应星期、一周日期、星期开始与结束日期的方法
  • 计算一段日期内的周末天数的php代码(星期六,星期日总和)
  • php获取本周星期一具体日期的方法
  • PHP计算一年多少个星期和每周的开始和结束日期
  • PHP获取当前日期所在星期(月份)的开始日期与结束日期(实现代码)
  • PHP获取一年中每个星期的开始和结束日期的方法
  • php获取是星期几的的一些常用姿势


  • 上一条:
    PHP实现的进度条效果详解
    下一条:
    php支持断点续传、分块下载的类
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 用Time Warden监控PHP中的代码处理时间(0个评论)
    • 在PHP中使用array_pop + yield实现读取超大型目录功能示例(0个评论)
    • Property Hooks RFC在PHP 8.4中越来越接近现实(0个评论)
    • 近期文章
    • 在windows10中升级go版本至1.24后LiteIDE的Ctrl+左击无法跳转问题解决方案(0个评论)
    • 智能合约Solidity学习CryptoZombie第四课:僵尸作战系统(0个评论)
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(95个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-06
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-11
    • 2017-12
    • 2018-01
    • 2018-02
    • 2018-03
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-09
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    • 2024-09
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客