FooKelvin Posted November 4, 2015 Share Posted November 4, 2015 Hi Everyone, After several round of review, I has been rejected. The output that preferred is: I'm not sure it's possible to do it and how to do it. As you can see, the header of program supported,Position,Evaluator will be increase base on the employee records. It's very flexible header, it's depends on number of form that employee supported. Employee can submit more than one form (differently). Each form contain of more than 1 question. The grand total is a sum of all of the form for individual employee. Each form have an evaluator/ position Actually, i have a different type of output previously. The output is more details : $sql = "SELECT EmpID,EmpName,FormName,questions,Scoring,Position,addedBy FROM [Advisory_BoardDB].[dbo].[masterView] WHERE submissionStatus <> 'Draft' ORDER BY EmpName ASC,FormName ASC"; $stmt = sqlsrv_query($conn, $sql); $data = array(); while (list($eid, $ename, $fname, $q,$score,$pos,$ab) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$eid])) { // initialize array for employee $data[$eid] = array('emp' => $ename, 'total' => 0, 'items' => array()); } // accumulate item data $data[$eid]['items'][] = array('form' => $fname,'questions'=> $q,'score' => $score,'position'=>$pos,'addby'=>$ab); $data[$eid]['total'] += $score; } $pcent20 = ceil(count($data)*20/100); //$pcent20 = ceil(count($data)*$finalPercentage); //uasort($data, function($a,$b){return $b['total']-$a['total'];}); uasort($data, function($a, $b) { $emp = $b['total'] - $a['total']; if($emp === 0) { return strcmp($a['emp'], $b['emp']); } return $emp; }); $data = array_slice($data, 0, $pcent20, true); //echo '<pre>',print_r($data, true),'</pre>'; // // Now output the array // echo <<<TABLE <table border="1" id="example"> <thead> <tr> <th>Employee ID</th> <th>Employee Name</th> <th>Grand Total</th> <th>Form</th> <th>Score</th> <th>Position</th> <th>Evaluator</th> </tr> <thead> TABLE; echo "<tbody>"; foreach ($data as $eid => $edata) { // how many items $numItems = count($edata['items']); echo "<tr> <td rowspan='$numItems'>$eid</td> <td rowspan='$numItems'>{$edata['emp']}</td> <td rowspan='$numItems'>{$edata['total']}</td>"; foreach ($edata['items'] as $k => $idata) { if ($k > 0) { echo "<tr class='hover-row'>"; } echo "<td>{$idata['form']} - {$idata['questions']}</td><td>{$idata['score']}</td><td>{$idata['position']}</td><td>{$idata['addby']}</td></tr>"; } } echo"</tbody>"; echo "</table>"; ?> For More details: http://forums.phpfreaks.com/topic/298608-sql-group-view-to-get-grand-total-and-details/ Million Thanks. Quote Link to comment Share on other sites More sharing options...
Solution QuickOldCar Posted November 8, 2015 Solution Share Posted November 8, 2015 Start using css and not tables. Create a wrapper for each row that can dynamically change via content within. Create dividers within those that can also dynamically change. Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 8, 2015 Share Posted November 8, 2015 Stop creating new threads on the same code/subject. You now have THREE threads going on this. Quote Link to comment Share on other sites More sharing options...
FooKelvin Posted November 9, 2015 Author Share Posted November 9, 2015 I cant find any delete function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.