Jump to content

Rank employees by performance (mysql, php) -- Help!


Recommended Posts

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:




  id  empid  edate  star  csat  cph  pa  credit  attachments  olrank 







And so far my script looks like...


<?php include_once("header.inc");?>
<table align="center" class="style6">
		<th>First Name</th>
		<th>Last Name</th>

$query = "SELECT *
          FROM empdata";

$res = mysql_query($query);
while($earray = mysql_fetch_array($res)) {
$empname = mysql_query("SELECT * FROM employees WHERE associd=".$earray['empid']);
    $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;

<?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.




EDITED: Formatting went wack. Corrected. Sorry! - Joey

Link to comment
Share on other sites

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 (%).

Link to comment
Share on other sites

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?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • 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.