This article mainly introduces the PHP implementation of the statistical data function, combined with the case analysis of PHP data query and display processing of relevant operational skills, the need for friends can refer to the following
This paper describes the statistical functions of PHP implementation. Share to everyone for your reference, as follows:
Statistics is the integration of basic data.
For SQL, there is the group by function, the Count function, the order by function, and so on.
SQL collects the data for statistical analysis.
In general, the data received after SQL processing, but also through the logic of PHP to organize.
In a certain format, display to the front desk.
is generally shown as an array, which is also the concept of data structures.
Look at this picture, basically think about the structure for
{Number of On-line, total, total, total, overall nuclear rate, {(Agent 1, Work No. 1, singular 1, number of shipments 1, nuclear single rate 1), (Agent 2, work number 2, odd 2, shipping 2, nuclear single rate 2)}}
If you use PHP to display the above structure, it will be well handled.
First, we get the initial processing data through SQL,
Do not underestimate this initial processing of data, good processing, will be very convenient.
Copy the Code code as follows:
Select A.user,count (order_id) as Subcount,b.passcount,c.full_name from Vicidial_order a left JOIN (select User,count ( order_id) as Passcount from Vicidial_order where time > Unix_timestamp (' 2015-11-7 ') and User_group = ' teamone ' and Veri Fysta = ' Y ' GROUP by user] B on a.user = B.user left joins vicidial_users c on a.user = C.user where time > Unix_timest AMP (' 2015-11-7 ') and A.user_group = ' Teamone ' GROUP by A.user;
SQL idea, collation Order table, with user to classify.
Gets the total number of orders submitted for each day count ().
Also to get everyone, the order is filtered by the total number of audits through where.
The association then queries other related data.
With these basic data, other relevant data can come out.
Using PHP to handle the fetch, where the variable name is clear, it is also helpful to read the code.
$select _sql = "Select A.user,count (order_id) as Subcount,b.passcount,c.full_name from Vicidial_order a left JOIN (select U Ser,count (order_id) as Passcount from Vicidial_order where time > Unix_timestamp (' ". $today." ') and User_group = ' ". $use R_group. "' and Verifysta = ' Y ' GROUP by user] B on a.user = B.user left joins vicidial_users c on a.user = C.user where ti Me > Unix_timestamp (' ". $today." ') and A.user_group = ' ". $user _group." ' GROUP by A.user "; $rows = Mysqli_query ($db _conn, $select _sql); $row _counts_list = Mysqli_num_rows ($rows); if ($row _coun Ts_list! = 0) {$i = 0; while ($rs = Mysqli_fetch_assoc ($rows))//MYSQLI_FETCH_ASSOC get the key value data Mysqli_fetch_field get a data mysqli_fetch_fields get multiple groups Data mysqli_fetch_row {$outData [' list '] [$i] [' user '] = $rs [' user ']; $outData [' list '] [$i] [' full_name '] = $rs [' Full_name ']; $outData [' list '] [$i] [' subcount '] = $rs [' Subcount ']; $outData [' list '] [$i] [' passcount '] = $rs [' Passcount ']; $outData [' list '] [$i] [' passrate '] = round ($rs ['Passcount ']/$rs [' Subcount ']) *100). " %"; $outData [' all_subcount '] + = $rs [' Subcount ']; $outData [' all_passcount '] + = $rs [' Passcount ']; $i + +; } $outData [' all_passrate '] = round (($outData [' All_passcount ']/$outData [' All_subcount ']) *100). " %"; $outData [' online_count '] = $row _counts_list; $outData [' average_subcount '] = round ($outData [' All_subcount ']/$outData [' Online_count '],1];}
Where Outdata is the type of data structure to output.
Array ([ list] = = Array ( [0] = = Array ( [user] = 8001 [full_name] = Wei [ Subcount] + 3 [Passcount] = 2 [passrate] = 67% ) [1] = = Array ( [user] = 8004 [Full_name] = Liu Qinghe [Subcount] = 2 [Passcount] = 2 [passrate] = 100% ) [2] = = Array ( [user] = 8005 [full_name] = Zhang Huoying [Subcount] = 4 [Passcount] = 3 [passrate] =& Gt 75% ) ) [All_subcount] = 9 [All_passcount] = 7 [all_passrate] + 78% [ Online_count] + 3 [Average_subcount] = 3)
After getting the data, everything is fine.
The page is ready to be set up, and then debug it yourself.
<!--begin--><?php foreach ($outData as $k = $v) {><p class= "col-xs-12 col-sm-6 Widget-container-col Ui-sortable "> <p class=" Widget-box widget-color-blue "> <p class=" Widget-header ">