jdorma0 Posted March 10, 2010 Share Posted March 10, 2010 I am trying to write a script that will allow the user to input data (people and their performance) into the database using a form, and then once this data enters the database I would like to be able to rank the people by their performance, thus helping management decide who gets their choice of hours versus the lower ranking employees. I've setup the database like this: empdata id empid edate star csat cph pa credit attachments olrank idempidedatestarcsatcphpacreditattachmentsolrank 14532010-02-288029712.0281%51%0 26582010-02-28258200-5.0255%360 335342010-02-281001515022.02%100%78%0 And so far my script looks like... <?php include_once("header.inc");?> <table align="center" class="style6"> <tr> <th>First Name</th> <th>Last Name</th> <th>Star</th> <th>CSAT</th> <th>CPH</th> <th>PA</th> <th>Credit</th> <th>Attachments</th> <th>Ranking</th> </tr> <?php $query = "SELECT * FROM empdata"; $res = mysql_query($query); $i=0; while($earray = mysql_fetch_array($res)) { $empname = mysql_query("SELECT * FROM employees WHERE associd=".$earray['empid']); $ename=mysql_fetch_array($empname); $emp = "<tr><td>".$ename['fname']; $emp .= "</td><td>".$ename['lname']; $emp .= "</td><td>".$earray['star']; $emp .= "</td><td>".$earray['csat']; $emp .= "</td><td>$".$earray['cph']; $emp .= "</td><td>".$earray['pa']; $emp .= "</td><td>".$earray['credit']; $emp .= "%</td><td>".$earray['attachments']; $emp .= "%</td><td>".$earray['olrank']; $emp .= "</td></tr>"; echo $emp; $i++; } ?> </table> <?php include_once("footer.inc");?> My main problem is figuring out how to do the formulas. If it were Excel I would simply use the rank function on each of the fields. I need to rank each field individually (cph, credit, pa, etc, etc) and rank each employee by that field, then add that to the olrank column. The olrank would be a sum of each of the ranks (example: credit 2nd, pa 1st, csat 4th would mean that person gets scored 7 pts) that I would just retrieve from the database using a reverse BY olrank directive. Any help would be appreciated. Thank you so much. I've been trying to figure out these formulas for days. Joey EDITED: Formatting went wack. Corrected. Sorry! - Joey Quote Link to comment https://forums.phpfreaks.com/topic/194707-rank-employees-by-performance-mysql-php-help/ Share on other sites More sharing options...
jdorma0 Posted March 10, 2010 Author Share Posted March 10, 2010 It also could be that I need to do the ranking when the data is first inserted into the database. But then again I realize the problem that I don't know how to rank the data given multiple rows (employee 1, 2, 3, 4, etc) .. again in Excel I would just use the rank() function to process it. But I have to get this web based and use the power of PHP to do that. Also, the fields credit and attachments would be the only ones using a percentage mark (%). Quote Link to comment https://forums.phpfreaks.com/topic/194707-rank-employees-by-performance-mysql-php-help/#findComment-1023966 Share on other sites More sharing options...
jdorma0 Posted March 10, 2010 Author Share Posted March 10, 2010 Additionally (sorry, the modify buton wasn't there!), the data is compared to each employee before going to the database if my thinking is correct. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/194707-rank-employees-by-performance-mysql-php-help/#findComment-1023994 Share on other sites More sharing options...
jdorma0 Posted March 10, 2010 Author Share Posted March 10, 2010 Okay, after another night of failure trying to figure this out I am going to go to bed. If anyone can help me out, I would greatly appreciate it, but it just seems like my topic keeps sliding off the first few pages =[ Any suggestions anyone? Quote Link to comment https://forums.phpfreaks.com/topic/194707-rank-employees-by-performance-mysql-php-help/#findComment-1024140 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.