473,508 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hours Calculated

1 New Member
I am having trouble with the following code. I need to have it calculate regular pay, overtime pay and gross pay and display it back to the user. Can anyone figure out where my problem lies.
[php]
<?php
//global variables
$wage = 0;
$hours = 0;
$error_count = 0;
$gross = 0;

$error_message = array();
?>

<html>
<head>
<title>Paycheck</title>
<link href="paycheck.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h1>Paycheck</h1>

<?php
//user input
retrieve_data($wage, $hours);

//validate
$error_messages = validate_verify_user_input($wage, $hours);

$error_count = count($error_messages);

//check errors
if($error_count > 0)
{
display_error_page($error_messages);
}

else
{
//processing
$gross = process_data($wage, $hours);
display_response_page($wage, $hours, $gross);
}

exit();
?>

<?php

function retrieve_data(&$wage, &$hours)
{
$wage = $_GET["wage"];
$hours = $_GET["hours"];
}


function validate_verify_user_input($wage, $hours)
{
$errors = array();

if(!is_numeric($wage) || !is_numeric($hours))
{
$errors[] = "Wage and hours must contain numeric information";
}

if($wage > 99.99)
{
$errors[] = "Wage must be less than 100%";
}

if($wage < .01)
{
$errors[] = "Wage must be greater than 0";
}

return $errors;
}

function display_error_page($error_messages)
{
echo "<body style='background-color:red; color:white'>";

echo "<h3>Hit your brower's back button and correct the following input errors:</h3>";

echo "<p class='center'>";

foreach($error_messages as $error)
{
echo $error."<br />";
}

echo "</p>";

echo "</body></html>";

}

function process_data($wage, $hours)
{
$gross = 0;
$reg_wage = 0;
$over_wage = 0;

$wage = $wage * .01;

do
{
$gross++;

for($x = 0; $x < 4; $x++)
{
$reg_wage = ($wage * $hours);
$over_wage = ($wage * 1.5) * $hours;
}
}

return $gross;
}

function display_response_page($wage, $hours, $gross)
{
echo "<body>";

echo "<h3>";

echo "Total gross amount ";

echo "<span class='under'>$gross</span>";

echo " Overtime pay $over_wage Regular pay $reg_wage ";

echo "</h3>";

echo "</body></html>";
}

?>
[/php]
Feb 15 '08 #1
3 1659
code green
1,726 Recognized Expert Top Contributor
Can anyone figure out where my problem lies.
You are not echoing out any variables so you cannot 'see' what is happening
Feb 15 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
Next time enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

moderator
Feb 15 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
Try to debug some: To start, put a print_r($_GET) at the top so you can see if any data is actually coming in via this array.

Ronald
Feb 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

22
14928
by: Drum2001 | last post by:
I have a table that tracks employee times. I have a column (Date/Time). Users, through a form, enter how long it takes them to complete a task. For example, 03:45 = 3 hours and 45 mins. I am...
3
15970
by: Stephen Chaplin | last post by:
I'm summing up time spent on jobs over a week, some of these jobs last greater than 24 hours and when access sums these up it appears that it starts again at 00:00 once it gets past 23:59. Is it...
0
1370
by: King | last post by:
Hi I have 2 queries where I calculated time elapsed. In the first I calculated time spent by a employee in group meetings and in the second query, I calculated time spent by an employee in...
18
13016
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.