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
https://forums.phpfreaks.com/topic/292643-sos-logical-and-inner-join-help-guys/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.