Exemplo n.º 1
0
            echo "The Average salary for the " . $searchstring . " position based on Total Earnings is Grand Total Salary: " . money_format('%i', $sum) . " divided by total number of records " . $totalrows . " = " . money_format('%i', $average) . "<br>";
            return 1;
        } else {
            // no data found, the program will return to the start page, but inform the user. The message may be visible on a slower system.
            echo "Sorry no data found for: " . $searchstring . "<br>";
            return 0;
        }
    }
}
//end of controller
// cleans and tests input for correctness
function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
//if (isset($_GET['name']))
if (isset($name)) {
    //instantiate the CalculateEarnings controller class
    $workhorse = new ModelClass();
    //then call the method
    $ret = $workhorse->getAverageSalary();
    //return final status
    if ($ret === 0) {
        echo "{module:model, message:No data found, the program, success: false}";
    } else {
        echo "{module:model, success: true}";
    }
}