1.获取诸如2014-05-10的时间
function get_time(n_day_ago) { var cur_date=new Date(); var dst_date=new Date(cur_date - n_day_ago*86400000); var dst_year=dst_date.getFullYear(); var dst_month=dst_date.getMonth()+1; var dst_day=dst_date.getDate(); var dst_formate_date=dst_year + "-" + (dst_month < 10 ? "0" + dst_month : dst_month) + "-" + (dst_day < 10 ? "0" + dst_day:dst_day ); return dst_formate_date; };
var highchart_option={ chart: { renderTo: 'upload_quantity', //DIV容器ID type: 'line', zoomType: 'x' }, title: { text: ' 图片上传', x: -20 //center }, subtitle: { text: ' 图片运维组', x: -20, }, xAxis: { labels: { rotation:90, }, lineWidth:1 }, yAxis: { title: { text: '数量(张)' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, tooltip: { valueSuffix: '张', crosshairs: true, shared: true }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, tickInterval:1, series: [{ }] }
highchart_option.xAxis.categories=json_date; highchart_option.series=json_data; highchart_option.xAxis.labels["step"]=Math.round(json_date.length / 20); new Highcharts.Chart(highchart_option);
3.php 实现小数保留若干位
$a=10.121212;
$b=round($a,2);
4.php实现打印出某个区间段的时间
ini_set('date.timezone','Asia/Shanghai'); $date_i=$date_from; $date_range=array(); while($date_i<=$date_to) { $date_range[]=$date_i; $date_i=date("Y-m-d",strtotime($date_i." +1 days ")); }
5.jquery 遍历数组
<script type="text/javascript"> $(function () { var div_array=['quantity','avg_capacity','avg_time','avg_rate']; $.each(div_array,function(key,val){ console.log(key+val); }); }); </script>
6.一个sql语句查询
SQL查询语句如下: select * from table where (ID = 10) or (ID = 32) or (ID = 22) or (ID = 76) or (ID = 13) or (ID = 44) 让结果按10,32,22,76,13,44的顺序检索出来,请问如何书写? select * from table where id in (10,32,22,76,13,44) order by field(id,10,32,22,76,13,44) desc
7.监听checkbox事件 jquery控制
$("input[type='checkbox']").bind("click", function(data) { var id=$(this).attr('id'); console.log(id); if(id=="upload_map") { if(data.target.checked==true) $("#map_div_upload_all").show(); else $("#map_div_upload_all").hide(); } if(id=="download_map") { if(data.target.checked==true) $("#map_div_download_all").show(); else $("#map_div_download_all").hide(); } });
$.each(data,function(key,val) { var append_str="<option></option>"; $.each(data[key],function(option_key,option_val){ append_str+="<option>"+option_val+"</option>"; }); $("#"+"curve_"+key).empty(); $("#"+"curve_"+key).append(append_str); });
$("#submit_curvebtn").click(function() { $.ajax({ url:"/imgbed_statistics/curve/control/get_ispcurve_info.php", type:"POST", data:$('#curve_form').serialize(), async:false, dataType:'json', success:function(data) { curve_option.series=data["data"]; curve_option.xAxis.categories=data["date"]; console.log(data["date"].length); curve_option.xAxis.labels["step"]=Math.round(data["date"].length / 20); if(data["date"].length>10) curve_option.xAxis.labels["rotation"]=90 new Highcharts.Chart(curve_option); }, error:function() { alert("error"); } }); });
$("#map_download_td").empty();
11.bootstrap的分页功能
var download_target=$('#map_download_pagination'); var download_page_option={ prev: '<', next: '>', left: 3, right: 1, page: 13, lastPage: 3, click: function(i) { download_page_option.page = i; download_target.pagination(download_page_option); $("#map_download_td").empty(); for(var k=0;k<12&&12*(i-1)+k<download_table.length;k++) { city_name=download_table[12*(i-1)+k]["name"]; city_count=download_table[12*(i-1)+k]["count"]; str="<tr><td>"+city_name+"</td><td>"+city_count+"</td></tr>"; $("#map_download_td").append(str); } } }; download_target.pagination(download_page_option);
解决方式:output_buffering = 4096或者output_buffering = on