Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created January 4, 2009 16:17
Show Gist options
  • Save mdarby/43094 to your computer and use it in GitHub Desktop.
Save mdarby/43094 to your computer and use it in GitHub Desktop.
function calc_pct_complete($job_id, $d) {
$pc = 0;
$sql = "some SQL query";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
$x = total_days($row[start_date], $d) / total_days($row[start_date], $row[end_date]);
if ($x < 0) {
$x = 0;
} elseif ($x > 1) {
$x = 1;
} elseif ($row[name] != "X" && $row[name] != "Y") {
$x = $x * $x;
}
$pc += $x * $row[pct_hours];
}
mysql_free_result($res);
return $pc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment