I am facing some problem in my code I want to calculate the total pay of the employers but unfortunately I am unable to figure it out. I want to add the total such like if the person works normal hours means (9 hours) and overtime as Monday to friday overtime <=3h his pay will be +15% and if overtime >3h it will be +22%. Saturday Normal hours will be +$6 hour, Sunday and holiday normal hours == +$8 hour, Weekend and holidays overtime hours == +40% and in the I' have to multiple the number of hours by the position. if the position is manager so I want to multiple it by $30 if not then the price will be $25. Here is my code:

// this php code //
<?php

$position = $hours = $overtime = $sunday = $saturday = $Wekened = 0;
if (isset($_GET['post']) && isset($_GET['hours']) && isset($_GET['overtime'])) && isset($_GET['Sunday']))  && isset($_GET['Saturday']))  && isset($_GET['weekend'])) 
{
  $post = $_GET['post'];  
  $hours = $_GET['hours'];
  if (!is_text($post)) || (!is_numeric(hours)) || (!is_numeric($overtime)) || (!is_numeric($saturday)) || (!is_numeric($sunday)) || (!is_numeric($weekend))
  {
    $res = NULL;
  }
  else
  {
  $cal = $_GET['opt'];
  switch($cal)
  {
    case 'add' and 'multiply':
      $res = ($overtime + $hours + sunday + saturday)  * position;

    default:
      $res = NULL;
  }
  }
}
?>
// display html on the same file
<html>
    <body>
        <form action="checkpart2.txt" method="GET"/>
        Postion:<input type="text" name="post"/><br/>
        Hours:  <input type="text" name="hours"/><br/>
        <div id="checkbox1">
        Overtime:
        <input id="Checkbox1" type="checkbox"/>
    </div>
        <select>
        <option type="text" name="opt" value="hour"> 1 </option>
        <option type="text" name="opt" value="hour"> 2 </option>
        <option type="text" name="opt" value="hour"> 3 </option>
        <option type="text" name="opt" value="hour"> 4 </option>
        <option type="text" name="opt" value="hour"> 5 </option>
        <option type="text" name="opt" value="hour"> 6 </option>
        <option type="text" name="opt" value="hour"> 7 </option>
        <option type="text" name="opt" value="hour"> 8 </option>
        </select>
        <br />
        Saturday:
        <input id="Checkbox1" type="checkbox"/>
        </div>
        <select>
        <option type="text" name="opt" value="hour"> 1 </option>
        <option type="text" name="opt" value="hour"> 2 </option>
        <option type="text" name="opt" value="hour"> 3 </option>
        <option type="text" name="opt" value="hour"> 4 </option>
        <option type="text" name="opt" value="hour"> 5 </option>
        <option type="text" name="opt" value="hour"> 6 </option>
        <option type="text" name="opt" value="hour"> 7 </option>
        <option type="text" name="opt" value="hour"> 8 </option>
        </select>
        <br />
            Sunday:
        <input id="Checkbox1" type="checkbox"/>
        </div>
        <select>
        <option type="text" name="opt" value="hour"> 1 </option>
        <option type="text" name="opt" value="hour"> 2 </option>
        <option type="text" name="opt" value="hour"> 3 </option>
        <option type="text" name="opt" value="hour"> 4 </option>
        <option type="text" name="opt" value="hour"> 5 </option>
        <option type="text" name="opt" value="hour"> 6 </option>
        <option type="text" name="opt" value="hour"> 7 </option>
        <option type="text" name="opt" value="hour"> 8 </option>
        </select>
    <br />
  <input type="submit" value="calculate"/>
</form>
<? if (isset($res) && $res != NULL): ?>
  <span class="result-label">Result:</span> <span class="result"><?=$res?></span>
<? endif ?>
</body>
</html>

Write down your inputs and requirements line by line, a line containing one action only. It will be much easier to convert to code.

thanks for that and you meant the alogorithm?

Correct. Break it down in small clear pieces. In the end it will almost look like code, and will be easy to convert to PHP.

Inputs are:
Position // It should work as when the user types manager the pay will be $30 else $25//
Monday hours to Friday hours // Now the main program is this " it should take the normal, overtime and weekend/ holidays working hours and it should multiple the number of hours to the pay of the position.
and the rest of the things I have already writing above. Thanks for the help @pritaeas

ohhh okay then just wait 5 min I'll post it..:)

Begin
    Hours <- 0
    Overtime <- 0
    pay <- 0
    total <- 0
    day1 to day 5 <- monday to friday
    saturday_hours <- +6/hours
    Sunday_hours <- +8/hours
    weekend_pay <- +40%
    Get Position
    Get Monday Hours
    Get Tuesday Hours
    Get Wednesday Hours
    Get Thursday Hours
    Get Friday Hours
    Get Saturday Hours
    Get Sunday Hours
    while position <> " "
        if position = manager 
            payy <- 30
        else
            pay <- 25
       end if 
       overtime <- day1 - 8.5
       if overtime <= 3 
           pay <- pay * 1.15
           overtime <- overtime * pay
       end if
       else
           pay <- pay * 1.22
           overtime <- overtime * pay
       Else
           pay <- pay 
       end if
           Day1 <- 8.5 * pay + overtime

       etc.....
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.