Space for google add

write a PHP script which will print a salary statement in the format given below, for a given department. (Accept department name from the user).



Consider the following entities and their relationships

Emp (emp_no,emp_name,address,phone,salary)

Dept (dept_no,dept_name,location)

Emp-Dept are related with one-many relationship Create a RDB in 3NF for the

above and solve following

Using above database write a PHP script which will print a salary statement in the

format given below, for a given department. (Accept department name from the

user).

Deparment Name : _________________

Maximum Salary Minimum Salary Sum Salary


ex5seta1.html

<html>

<body>

<form method="post" action="ex5seta1.php">

Enter department name:

<input type="text" name="dname"><br>

<input type='submit' name='submit' value='submit'>

<input type='reset' name='reset' value='reset'>

</form>

</body>

</html>



ex5seta1.php

<?php

$dept=$_POST['dname'];

$db=pg_connect("host=192.168.100.10 user=tybcs8 dbname=tybcs8");

if(!$db)

{

echo "An error occured";

exit;

}

else

{

echo "successfully connected";

$result=pg_query($db,"select max(salary),min(salary),sum(salary) from emp where dno in(select dno from dept where dname='".$dept."')");

if(!$result)

{

echo "An error occured";

exit;

}

while($row=pg_fetch_array($result))

{

echo "<table border=1><th>Maximum salary</th><th>Minimum salary</th><th>sum salary</th>";

echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";

}

echo "</table>";

}

pg_close($db);

?>



Post a Comment

0 Comments