Considerer the following entities and their relationships
project(pno integer, p_name char(30), ptype char(20),duration integer)
employee (eno integer, e_name char (20), qualification char (15), joindate date)
The relationship between project - employee: M-M, with descriptive attributes as
start_date (date), no_of_hours_worked (integer).
Using above database write a script in PHP to accept a project name from user and
display information of employees working on the project.
ex5setb1.html
<html>
<body>
<form method="post" action="ex5setb1.php">
Enter project name:
<input type="text" name="pname"><br>
<input type='submit' name='submit' value='submit'>
<input type='reset' name='reset' value='reset'>
</form>
</body>
</html>
ex5setb1.php
<?php
$str1=$_POST['pname'];
$conn_str="host=192.168.100.10 port=5432 dbname=tybcs8 user=tybcs8";
$conn=pg_connect("$conn_str");
if(!$conn)
{
echo"fail";
}
else
{
$q="select * from project,emp1,p_e where project.pno=p_e.pno and emp1.eno=p_e.eno and pname='$str1'";
$rs=pg_query($conn,"$q");
if(!$rs)
{
echo "An error Occurred.<br>";
}
echo"<table border=2>";
echo"<tr>";
echo"<th>Emp no</th>";
echo"<th>Emp name</th>";
echo"<th>qualificaton</th>";
echo"<th>join date</th>";
echo"</tr>";
while($row=pg_fetch_assoc($rs))
{
echo"<tr>";
echo"<td>$row[eno]</td>";
echo"<td>$row[ename]</td>";
echo"<td>$row[qualification]</td>";
echo"<td>$row[joindate]</td>";
echo"</tr>";
}
echo"</table>";
}
?>
0 Comments
If anyone has Doubts or suggestions please let me know