Order of Principles report
See a treasure, a cat sort, I want to Tiger, tinker myself one.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvd3vqawfuz3dlatu2nw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/center ">
The principle records such as the following:
1. Reception section
<table> <tr class= "Proghead" > <td class= "Canclick progsort1" onclick= "Sort_prog (0)" > Study number </td> <td class= "Canclick progsort2" onclick= "Sort_prog (1)" > name </td> </tr></ Table>
2. CSS Section
. Upsort:hover,.upsort{background:rgb (0,161,222) URL (./css/up.png) no-repeat center right; color: #fff;}. Downsort:hover,. Downsort{background:rgb (0,161,222) URL (./css/down.png) No-repeat center right; color: #fff;}
2. js section
function Sort_prog
var sortprog_flag = [0,0];var sortprog_col = [' Sid ', ' username ']; Sort filter function Sort_prog (num) {Clear_arr (sortprog_flag,num); Change Display identity 1 ascending if (sortprog_flag[num] = = 0 | | Sortprog_flag[num] = = = 2) {Sortprog_flag[num] = 1;} 2 descending otherwise do not sort else if (sortprog_flag[num] = = 1) {Sortprog_flag[num] = 2;} if (num >= 0) {var htmlcode = '; $.ajax ({' URL ': './ajax.php ', ' Data ': Get_param (' prog '), ' dataType ': ' Text ', ' type ': ' Post ', ' async ': false, ' success ': function (data) {if (data) {$ ('. Curseload '). Hide (); htmlcode = data;}}); $ ('. Progreport '). HTML (htmlcode);//Change Display identity if (sortprog_flag[num] = = 2) {$ ('. ') +obj). addclass (' Downsort '). Removeclass (' Upsort ');} else if (sortprog_flag[num] = = 1) {$ ('. ') +obj). addclass (' Upsort '). Removeclass (' Downsort ');} $('.' +obj). Siblings (). Removeclass (' Downsort '). Removeclass (' Upsort ');} Else{clear_arr (sortprog_flag,-1); $.ajax ({' URL ': './ajax.php ', ' Data ': Get_param (' prog '), ' dataType ': ' Text ', ' type ': ' Post ', ' Success ': function (data) { if (data) {$ ('. Prog '). HTML (data);}});} }//array-Clear 0 initializationfunction Clear_arr (arr, index) {var len = arr.length; for (var i= 0; i < len; i++) {if (i! = index) {Arr[i] = 0; }}}//array get click Index function Get_index (arr) {var len = arr.length; var index =-1; for (var i = 0; i < len; i++) {if (arr[i]! = 0) {index = i; }} return index; }//Parameters gets/Gets the parameter function Get_param (type) {if (type = = ' prog ') {var num = Get_index (sort_flag); var sid = $ ('. Sid '). Val (); var username = $ ('. Username '). Val (); return {' SID ': Sid, ' username ': username, ' sort_col ': sortprog_col[num], ' sort_type ': Sortprog_flag[num]}; } }
3. PHP section
Class reportclass{//Sort By column public function Multi_array_sort ($multi _array, $sort _key, $sort =sort_asc) {$sorttype = Optional_param (' SortType ', 1, Param_raw), if ($sorttype = = 1) {$sort =sort_asc;} else if ($sorttype = = 2) {$sort =sort_desc;} if (Is_array ($multi _array)) {foreach ($multi _array as $row _array) {if (Is_array ($row _array)) {//Convert utf-8 Chinese to gbk Chinese Pinyin sort $key _array[] = iconv (' UTF-8 ', ' GBK ', strip_tags ($row _array[$sort _key]));} Else{return false;}}} Else{return false;} Array_multisort ($key _array, $sort, $multi _array); return $multi _array;} Public Function Print_Report () {$arr = Get_report (); $sort _col = $_post[' Sort_col ']; $sort _type = $_post[' Sort_type '];i F ($sort _type = = 1) {$sort = SORT_ASC;} else if ($sort _type = = 2) {$sort = Sort_desc;} $newarr = $this->multi_array_sort ($arr, $sort _col, $sort); $this->show_report ();} Implement get report information two-dimensional array public function Get_report () {}//Print report based on two-dimensional array public function Show_report () {}}
The code is not complete. But the train of thought is complete. Welcome to the different views of the brick
Then attached to the following I personally make a statement of the idea diagram:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvd3vqawfuz3dlatu2nw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/center ">
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
PHP report sorting and production concepts