Results 1 to 2 of 2

Thread: Checking in mysql database the data before compute the deduction

  1. #1
    Join Date
    Oct 2011
    Posts
    39
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Checking in mysql database the data before compute the deduction

    Good day!

    I have table in my database which I could check the range of compensatin,monthly salary credit, monthly contribution.

    Now i am in the process of analyzing how can I get the monthly contribution of employee it is depend on their basic pay.

    I have this code for getting the basic pay of employee:
    PHP Code:
     $sql "SELECT em.EMP_NO, w.RATE, e.Hours FROM $ADODB_DB.wage w, $ADODB_DB.employment em,  $PAYROLL.earnings e WHERE w.EMP_ID = '$currentEmpID' AND em.EMP_ID = '$currentEmpID' AND e.EMP_NO = em.EMP_NO";
      
    $RsEarnings $conn2->Execute($sql);

      
    $Rate      trim($RsEarnings->fields['RATE']);
      
    $Hours      trim($RsEarnings->fields['Hours']);

      
    $Hours substr($Hours05);
      
    $Hours str_replace(':''.'$Hours);
      
     
    $Amount $_POST["Amount"];
     
    $Amount mysql_real_escape_string($Amount); 
     
     
    $Amount round(($Hours/8)* $Rate2); 


      
    $smarty->assign('Rate'$Rate);
      
    $smarty->assign('Hours'$Hours);
      
    $smarty->assign('Amount'$Amount); 
    the Amount is the Basic Pay and it is only display the basic pay not yet save in the database.

    and I have table deduction that has fields:
    RangeCompensation varchar
    MonthlySalaryCredit varchar
    MonthlyContribution varchar

    Example data:
    1000 - 1249.99 1000 33.30
    1250 - 1749.99 1500 50.00
    1750 - 2249.99 2000 66.70 and so on.....

    The deduction is base on the Amount, what should be my query or condition to check if what would be his monthlydeduction.

    For example Amount or Basic pay is 5422.5

    Where should I base is it in MonthlySalaryCredit? or should separate the rangecompensation into two then i will based on that? to get his monthly deduction


    Thank you so much...

  2. #2
    Join Date
    Oct 2011
    Posts
    39
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    I tried this code: and I add Ref_No in my table

    PHP Code:
    $sql "SELECT em.EMP_ID, em.EMP_NO, s.Ref_No s.RangeCompensation, s.MonthlySalaryCredit, s.EmployeeShare
            FROM 
    $PAYROLL.sss s, $ADODB_DB.employmet em 
            WHERE em.EMP_ID = '
    $currentEmpID'";
    $rsSSS $conn2->Execute($sql);

    $Ref_No $rsSSS->fields['Ref_No'];

    if(
    $Ref_No 1){
         
    $SSS = (80.70 2);
    }
    elseif(
    $Ref_No 10){
         
    $SSS = (183.30 2);
    }
    elseif(
    $Ref_No 8){
         
    $SSS = (150.00 2);
    }
    else{
        
    $SSS 0;


    $smarty->assign('SSS'$SSS); 
    and the result is:

    the $SSS has always a value of 40.35, that's means that only the if statement was read...

    What's wrong in my syntax?

    Thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •