コード例 #1
0
ファイル: 14.php プロジェクト: henkerik/typing
function fac($n)
{
    if ($n == 0) {
        return 1;
    } else {
        return $n * fac($n - 1);
    }
}
コード例 #2
0
ファイル: factorial.php プロジェクト: rjh427/php-101
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));
}
コード例 #3
0
ファイル: filter.php プロジェクト: smilecs/microfinance
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'];
コード例 #4
0
ファイル: test2.php プロジェクト: robstoll/tins-benchmark
function fac($n)
{
    return $n > 0 ? $n * fac($n) : $n;
}