Jump to content

SOS logical and inner join help guys


phpheart

Recommended Posts

im trying to make a salary system which would display a month salary according to login hours so i got two different  tables storing data like

 

1. users table  id, name, password, salary

2.attendance table  id, user_id, Employee_Name, Remark, Login_Hours, Date

 

so what im looking to do is fetch all users id, name and salary from users table and then match it with attendance user_id,Employee_Name ,Login_Hours, table and then also count numbers of result for a particular year-month so that i could do the hourly wage calculation.

 

could someone help out i got no idea how to achieve it

 

apprieciate your help,

thanks

 

i tried something like this it does output something but still dunno how to match results of both tables and get result

 

 

$date = '2014-11';

$query1 = "SELECT COUNT(*) as num FROM attendance WHERE Date LIKE '%".$date."%' AND Employee_Name='moses'";
$total_pages = mysql_fetch_array(mysql_query($query1));
     $total_res = $total_res[num]; // total rows counting of total office days of a month
    
$result2=mysql_query("SELECT id, user_id, Employee_Name, Remark, SUM(Login_Hours), Date FROM attendance WHERE Employee_Name='moses'");
while($row = mysql_fetch_array($result2)){
     echo $sal_to_month = 9000/$total_res; //9000 is salary should be fetched from users table
     echo '<br/>';
       echo  $sal_to_month/9*$row['SUM(Login_Hours)'];
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.