Jump to content

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


jdorma0

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:

 

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

Link to post
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 post
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 post
Share on other sites

Archived

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.