function fac($n) { if ($n == 0) { return 1; } else { return $n * fac($n - 1); } }
function nCk($n, $k) { if ($n === 0) { die('Total number of items cannot be 0.'); } if ($n < $k) { die('Number of items taken cannot be greater than total number of items.'); } if ($k == 0) { return $n; } return fac($n) / (fac($n - $k) * fac($k)); }
function dept($dept) { if (!empty($dept)) { $msg = "dept = '{$dept}' AND "; return $msg; } } function sex($sex) { if (!empty($sex)) { $msg = "sex = '{$sex}' "; return $msg; } } $top = "\n<table class=table id=tableentry>\n<thead>\n <tr>\n <th>S/N</th>\n <th>EMP NO</th>\n <th>TITLE</th>\n <th>FULLNAME</th>\n <th>STATE</th>\n <th>LGA</th>\n <th>ADDRESS</th>\n <th>PHONE</th>\n <th>DEPARTMENT</th>\n <th>SEX</th>\n <th>EMAIL</th>\n </tr>\n</thead>\n<tbody>"; $fac = fac($faculty); if (empty($dept) && empty($sex)) { $fac = "customer.faculty = '{$faculty}' "; } $dep = dept($dept); if (empty($sex) && !empty($dept)) { $dep = "dept = '{$dept}' "; } $sex = sex($sex); $query = $fac . $dep . $sex; $result = query("SELECT priviledge, employee_no, title, surname, firstname, dep_name, lga, state, customer.id, phone, address, email, sex FROM customer LEFT JOIN department ON customer.dept=department.id WHERE {$query}"); $i = 0; $body = ''; while ($row = mysql_fetch_array($result)) { ++$i; $emp_no = $row['employee_no'];
function fac($n) { return $n > 0 ? $n * fac($n) : $n; }