forked from gauravraul/Payroll_Management_System-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectSalary.php
73 lines (54 loc) · 2.07 KB
/
selectSalary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
if ($user == "admin"){
$sql_statement = "SELECT * FROM employee AS e INNER JOIN salary AS s ON e.Emp_id = s.Emp_id";
}else{
$sql_statement = "SELECT * FROM employee AS e INNER JOIN salary AS s ON e.Emp_id = s.Emp_id WHERE e.Branch_name IN (SELECT Branch_name From admin WHERE username = '".$user."') ";
}
$result = mysqli_query($db,$sql_statement);
$outputDisplay = " ";
$myrowcount = 0;
if(!$result){
$outputDisplay .= "<br><font color=red>mysqli No: ".mysqli_errno($db);
$outputDisplay .= "<br>mysqli Error: ".mysqli_error();
$outputDisplay .= "<br>SQL Statement: ".$sql_statement;
$outputDisplay .= "<br>mysqli Affected Rows: ".mysqli_affected_rows()."</font><br>";
}else{
$outputDisplay .= "<h3>Salary Details : </h3>";
$outputDisplay .='<center><table border=1 style="color:black;">';
$outputDisplay .='<tr><th>Emp_id</th><th>Emp_name</th><th>Dept</th><th>Desgn</th><th>Branch_name</th><th>Basic_sal</th><th>Allowance</th><th>DRA</th><th>Advance</th></tr>';
$numresults = mysqli_num_rows($result);
for ($i = 0; $i < $numresults ; $i++)
{
if(!($i%2)==0)
{
$outputDisplay .="<tr style=\"background-color: #f5deb3;\">";
}else{
$outputDisplay .="<tr style=\"background-color: white;\">";
}
$row = mysqli_fetch_array($result);
$emp_id = $row['Emp_id'];
$emp_name = $row['Emp_name'];
$dept = $row['Dept_name'];
$desgn = $row['Desgn'];
$branch = $row['Branch_name'];
$basic = $row['Basic_sal'];
$allowance= $row['Allowance'];
$dra = $row['DRA'];
$advance= $row['Advance'];
$outputDisplay .="<td>".$emp_id."</td>";
$outputDisplay .="<td>".$emp_name."</td>";
$outputDisplay .="<td>".$dept."</td>";
$outputDisplay .="<td>".$desgn."</td>";
$outputDisplay .="<td>".$branch."</td>";
$outputDisplay .="<td>".$basic."</td>";
$outputDisplay .="<td>".$allowance."</td>";
$outputDisplay .="<td>".$dra."</td>";
$outputDisplay .="<td>".$advance."</td>";
$outputDisplay .= "</tr>";
$myrowcount++;
}
$outputDisplay .= "</table></center>";
$outputDisplay .= "Number of Rows : ".$myrowcount;
echo $outputDisplay;
}
?>