Jump to content

FooKelvin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by FooKelvin

  1. Hi, i would like to sort the total and name with different type of sorting. uasort($data, function($a, $b) { $total = $b['total'] - $a['total']; //SORT BY DESC if($total === 0) { return strcmp($b['emp'], $a['emp']); // THIS line need to sort by ASC } return $total; }); Sort Total by DESC at the same time, sort emp BY ASC
  2. Hi Barand, The sorting function is working correctly. =) btw, is there any different for $pcent20 = ceil(count($data)/5); $data = array_slice($data, 0, $pcent20, true); and also the top 20 for ms sql. SELECT Top 20 Percent EmpID,EmpName,sum(Scoring) AS GrandTotal FROM [SubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear='2015' group by EmpID,EmpName ORDER BY GrandTotal DESC
  3. Hi Barand, i think i fixed my problem. I overlook, actually the form and employee id will repeat at each table. The only thing that unique is the subgroup. so i link it, i think the output is correct. Thank You Barand. Have a nice day! btw, how to close topic?
  4. Yes Barand. I have more than one record for each employee in EmployeeDetails table. I try to join like this and still give me repeated output.
  5. Problem solved!
  6. Question Posted: http://forums.phpfreaks.com/topic/298790-ms-sql-join-view-table-help/ Thank You everyone.
  7. Hello, I have a question regarding SQL. Please refer my attachment below: Query 1: SELECT dbo.[evaluation[Submit]]].FormID, dbo.empDB.Name, dbo.FormTbl.FormName, dbo.[evaluation[Submit]]].groupName, dbo.[evaluation[Submit]]].subGroup, dbo.subgrouptbl.subgroupName FROM dbo.[evaluation[Submit]]] INNER JOIN dbo.empDB ON dbo.[evaluation[Submit]]].EmpID = dbo.empDB.EmployeeID INNER JOIN dbo.FormTbl ON dbo.[evaluation[Submit]]].FormID = dbo.FormTbl.FormID INNER JOIN dbo.subgrouptbl ON dbo.[evaluation[Submit]]].subGroup = dbo.subgrouptbl.subgroupID WHERE (dbo.[evaluation[Submit]]].EmpID = '00001') This view of table give me correct of the output. Which give me 36 of results. Please refer attachment below: But, when i try to put additional table which i need to indicated whether the form is completed or draft, it's because i do not want to show "draft" form in the table. Have a look on the table below: After i added this table into my view, the output is repeated 2 times and give me 72 of results. Query 2: SELECT dbo.[evaluation[Submit]]].FormID, dbo.empDB.Name, dbo.FormTbl.FormName, dbo.[evaluation[Submit]]].groupName, dbo.[evaluation[Submit]]].subGroup, dbo.subgrouptbl.subgroupName, dbo.EmployeeDetails.submissionStatus FROM dbo.[evaluation[Submit]]] INNER JOIN dbo.empDB ON dbo.[evaluation[Submit]]].EmpID = dbo.empDB.EmployeeID INNER JOIN dbo.FormTbl ON dbo.[evaluation[Submit]]].FormID = dbo.FormTbl.FormID INNER JOIN dbo.subgrouptbl ON dbo.[evaluation[Submit]]].subGroup = dbo.subgrouptbl.subgroupID INNER JOIN dbo.EmployeeDetails ON dbo.empDB.EmployeeID = dbo.EmployeeDetails.EmpID WHERE (dbo.[evaluation[Submit]]].EmpID = '00001')
  8. first query which give me correct outputs: SELECT dbo.[evaluation[Submit]]].FormID, dbo.empDB.Name, dbo.FormTbl.FormName, dbo.[evaluation[Submit]]].groupName, dbo.[evaluation[Submit]]].subGroup, dbo.subgrouptbl.subgroupName FROM dbo.[evaluation[Submit]]] INNER JOIN dbo.empDB ON dbo.[evaluation[Submit]]].EmpID = dbo.empDB.EmployeeID INNER JOIN dbo.FormTbl ON dbo.[evaluation[Submit]]].FormID = dbo.FormTbl.FormID INNER JOIN dbo.subgrouptbl ON dbo.[evaluation[Submit]]].subGroup = dbo.subgrouptbl.subgroupID WHERE (dbo.[evaluation[Submit]]].EmpID = '00001') 2nd query that gives me wrong output: SELECT dbo.[evaluation[Submit]]].FormID, dbo.empDB.Name, dbo.FormTbl.FormName, dbo.[evaluation[Submit]]].groupName, dbo.[evaluation[Submit]]].subGroup, dbo.subgrouptbl.subgroupName, dbo.EmployeeDetails.submissionStatus FROM dbo.[evaluation[Submit]]] INNER JOIN dbo.empDB ON dbo.[evaluation[Submit]]].EmpID = dbo.empDB.EmployeeID INNER JOIN dbo.FormTbl ON dbo.[evaluation[Submit]]].FormID = dbo.FormTbl.FormID INNER JOIN dbo.subgrouptbl ON dbo.[evaluation[Submit]]].subGroup = dbo.subgrouptbl.subgroupID INNER JOIN dbo.EmployeeDetails ON dbo.empDB.EmployeeID = dbo.EmployeeDetails.EmpID WHERE (dbo.[evaluation[Submit]]].EmpID = '00001') Please Help..Thank You
  9. Hello, I have a question regarding SQL. Please refer my attachment below: This view of table give me correct of the output. Which give me 36 of results. Please refer attachment below: But, when i try to put additional table which i need to indicated whether the form is completed or draft, it's because i do not want to show "draft" form in the table. Have a look on the table below: After i added this table into my view, the output is repeated 2 times and give me 72 of results.
  10. Wondering Am I doing the correct thing. Im using qtip2 plug in to show something from another page content. I have 2 pages of php. aa.php <html> <head> <title>My site</title> <!-- CSS file --> <link type="text/css" rel="stylesheet" href="http://cdn.jsdelivr.net/qtip2/2.2.1/jquery.qtip.css" /> </head> <body> <!-- jQuery FIRST i.e. before qTip (and all other scripts too usually) --> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <!-- Include either the minifed or production version, NOT both!! --> <script type="text/javascript" src="http://cdn.jsdelivr.net/qtip2/2.2.1/jquery.qtip.js"></script> <!-- Optional: imagesLoaded script to better support images inside your tooltips --> <script type="text/javascript" src="/path/to/jquery.imagesloaded.pkg.min.js"></script> <a href="#">Test</a> <script type="text/javascript"> $('a').qtip({ content: { text: function(event, api) { $.ajax({ url: 'aaCal.php', // URL to the JSON file dataType: 'json', // Tell it we're retrieving JSON }) .then(function(data) { /* Process the retrieved JSON object * Retrieve a specific attribute from our parsed * JSON string and set the tooltip content. */ var content = 'My name is ' + data.person.firstName; // Now we set the content manually (required!) api.set('content.text', content); }, function(xhr, status, error) { // Upon failure... set the tooltip content to the status and error value api.set('content.text', status + ': ' + error); }); return 'Loading...', // Set some initial loading text } } }); Another page aaCal.php $arr = array('person' =>array('firstname' => "Foo")); echo json_encode($arr); The output of aaCal.php is {"person":{"firstname":"Foo"}}. reference plug in guide: http://qtip2.com/guides
  11. For example, IE able to have a script that allow user to set a reminder, set appointment without opening the outlook.
  12. Am i putting the correct place: while (list($eid, $ename, $fname, $score) = 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,'score' => $score); $data[$eid]['total'] += $score; } uasort($data, function($a,$b){return $b['total']-$a['total'];}); The output shows the total is sorting, but the forms displaying repeatedly.
  13. Yup. The top 20 percent that i referring is : For example: 150 Employees out of 20% of the Highest Total. Meaning that, the 30 employees with the highest total will be selected.
  14. Oops Sorry, Barand, I didn't update the query.
  15. Hi Barand, Thank You. But with that query, how I able to select Top 20 Percent, and Grand Total ORDER BY DESC?
  16. It's because some of the script not able to use in Chrome. But overall Chrome performs it quite fast.
  17. Sorry Barand, i can't get what you mean. you mean i can use ajax to get what output that i expect? After i take into consideration, i will prefer all data into one table instead of mouse hover. But i have no idea how to combine data from different query.
  18. Hi Barand, i put the second query inside the for each? $sql = "SELECT EmpID,EmpName,sum(Scoring) AS GrandTotal FROM [evaluationSubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear=$currentYear group by EmpID,EmpName ORDER BY GrandTotal DESC"; $stmt = sqlsrv_query($conn, $sql); $data = array(); while (list($eid, $en,$gt) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$eid])) { $data[$eid]['EmpID'] = $eid; $data[$eid]['EmpName'] = $en; $data[$eid]['GrandTotal'] = $gt; } } /********************************************************** * create table from array data ***********************************************************/ foreach ($data as $eid=>$gdata) { $trows .= "<tr><td>{$gdata['EmpID']}</td>" . "<td class='cn'>{$gdata['EmpName']}</td>" . "<td>{$gdata['GrandTotal']}</td>"; $trows .= "</tr>\n"; foreach () { //SECOND QUERY GOES HERE? } } ?> <table border='1' style='border-collapse: collapse;'> <?php echo $tableHeads ?> <?php echo $trows; ?> </table> Expected Output: Current Output: Thank You
  19. Hi All, not sure whether have this function available. I currently using chrome, can i set some < a href > or <id> to allow user to click in new window with different browser? for example: IE.
  20. Hi Guys, I have a system to keep track the scoring from different form. So, Initially when come to the reporting, i just accumulative different scoring from different form to get Grand Total. The Output that i have: The query that i use is : SELECT EmpID,EmpName,sum(Scoring) AS GrandTotal FROM [SubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear='2015' group by EmpID,EmpName ORDER BY GrandTotal DESC But, the feedback that i received, user request to have details, where this Grand Total come from which form? So I am thinking to allow user mouse over the Grand Total to show in details. Of course Only show individual details. For example, if i mouse over grand total for James, only James details will show up. Example: Query: SELECT EmpID,EmpName,[FormName],sum(Scoring) AS GrandTotal FROM [SubmittedForm] WHERE submissionStatus <> 'Draft' AND fiscalYear='2015' group by EmpID,EmpName,[FormName] ORDER BY GrandTotal DESC So, I am quite confusing is there any query can get what i need. I can know the accumulative of all forms and also individual forms. Or i only can do some if else matching on my programming sides?
  21. Barand Awesome! Tell me if my explanation wrong, $cdata['events'] as $m This statement is convert start date to months? Then each $m will loop for each column?
  22. Thanks Barand. PDO, a new thing for me. Thanks A lot!
  23. Hi Barand, The inspect element shows: <div class="add_more" data-id="c02" data-month="">+</div> when i try to var_dump($m) it show NULL
  24. Hi, Is that possible to connect to microsoft sql server by using mysqli? Currently i connected by using sqlsrv. For example, $serverName = "servername.com"; //serverName\instanceName $connectionInfo = array("Database" => "DB1", "UID" => "user99", "PWD" => "12345"); $conn = sqlsrv_connect($serverName, $connectionInfo); i have try quite some time to use mysqli to connect. But I keep getting errors.. Thank You
  25. Hi Barand, I would like to expand to have some function in this table. For convenience purpose, is good to build a feature to allow user to add the planning start date in the same page. So, I plan to have a "add" icon inside each of the column. Have a look with the attachment. Currently i added some code to have an "add" icon. What i propose is, when user click the "add" icon, a screen will pop up and request for some information, for example, Course ID, Course Name, Start Date and End Date. Below are some of the changes: $trows .= "<td class='dt'>" . join('<br>', $dates) . "<div class='add_more|$cid'>+</a></div>"; The reason i put in <div class='add_more|$cid'> is to make each column to have a course id. But how I to get the months name for each column? The purpose of get the months name is to pass to the pop up screen date picker to allow user to choose date for the particular month only. For example, User click "add" icon for November, so in the pop up screen, the date picker should only allow user to choose November month only.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.