2015.07.10后台搜索条件保持及数据统计

今天:

一、后台搜索条件保持

后台搜索条件保持原理:

    1.在点击搜索按钮时,将搜索条件保存在jscookie中

    2.确定上一个页面的范围,保证上一个页面是以上范围内的时显示上一次存进cookie的值

    3.cookie中存储的搜索条件传给query搜素条件  cookie中存储的搜索条件显示在搜索条件框中

后台搜索条件保持实现: 

1.包含     jquery.cookie.js   search_keep.js


2. //为搜索条件保持传值 var uri = '/Job/getJoblist'; var lastPages = "/Job/jobSet"; //上一个页面中一定包含的字符串,多个用","分割
//等号前面是搜索框的id,等号后面是query中的名              
 var slecterStr = "start_time=startTime&end_time=endTime&checkinfo=checkinfo&title=title&cpname=cpname&expertid=expertid"; if(first_keep(lastPages,uri,slecterStr)===false){return;} $.cookie("cookie_name",null); //将之前的cookie清空 
3. //将搜索条件存储在cookie中,这里的等号前面等于上面的slecterStr变量的等号后面 var query = "checkinfo=" + checkinfo + "&cpname=" + cpname + "&title=" + title + "&expertid=" + expertid + "&startTime=" + startTime + "&endTime=" + endTime;
$.cookie("cookie_name",query);

二、数据统计

1.SELECT FROM_UNIXTIME(posttime,'%Y-%m') as days,count(DISTINCT t_id) as c FROM `stj_record`  GROUP BY days order by days desc;

+---------+----+


| days    | c  |


+---------+----+


| 2015-06 |  3 |


| 2015-05 |  1 |


| 2015-04 |  2 |


| 2015-03 |  8 |


| 2015-02 | 12 |


| 2015-01 | 25 |


| 2014-12 | 23 |


| 2014-11 | 15 |


| 2014-10 | 28 |


+---------+----+


2.SELECT FROM_UNIXTIME(posttime,'%Y-%m') as days,count(id) as c FROM `stj_record`  GROUP BY days order by days desc;

+---------+-----+

| days    | c   |

+---------+-----+

| 2015-06 |  67 |

| 2015-05 |   9 |

| 2015-04 |   4 |

| 2015-03 |  22 |

| 2015-02 |  34 |

| 2015-01 | 111 |

| 2014-12 | 112 |

| 2014-11 | 151 |

| 2014-10 |  66 |

+---------+-----+

3 是1和2的合并

SELECT FROM_UNIXTIME(posttime,'%Y-%m') as days,count(id) as c,count(DISTINCT t_id) as dc FROM `stj_record`   GROUP BY days order by days desc;

+---------+-----+----+

| days    | c   | dc |

+---------+-----+----+

| 2015-06 |  67 |  3 |

| 2015-05 |   9 |  1 |

| 2015-04 |   4 |  2 |

| 2015-03 |  22 |  8 |

| 2015-02 |  34 | 12 |

| 2015-01 | 111 | 25 |

| 2014-12 | 112 | 23 |

| 2014-11 | 151 | 15 |

| 2014-10 |  66 | 28 |

+---------+-----+----+



1.select  distinct  t_id  from stj_record ;正常,得到t_id不重复的结果

2.select distinct   t_id , b_id  from stj_record  ;正常,得到t_id与b_id都不重复的结果

3.select   id,distinct  t_id  from stj_record ; 报错

4.select  id,count(distinct t_id)  from stj_record; 正常,

+-----+----------------------+-------+
| id  | count(distinct t_id) | bt_id |
+-----+----------------------+-------+
| 677 |                   76 |   421 |
+-----+----------------------+-------+

明天:

私人定制程序

企业程序

经验:第一天写的代码,上线前需要测一遍,然后隔天需要再测一遍,当时编写的思路和隔天跳出那个思维的思路是不一样的,隔天再检查能发现很多问题。

posted @ 2015-07-11 10:03  笑月儿  Views(210)  Comments(0)    收藏  举报