$username="user";
$password="password";
$database="company";
$dno=$_GET['dno'];
mysql_connect("host.domain.edu",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT dname,mgrssn,mgrstartdate,lname,fname FROM department,employee where dnumber=$dno and mgrssn=ssn";
$result=mysql_query($query);
$num=mysql_numrows($result);
$dname=mysql_result($result,0,"dname");
$mssn=mysql_result($result,0,"mgrssn");
$mstart=mysql_result($result,0,"mgrstartdate");
$mlname=mysql_result($result,0,"lname");
$mfname=mysql_result($result,0,"fname");
echo "Department: ", $dname;
echo "Manager: ", $mlname, ", ", $mfname, "";
echo "Manager Start Date: ", $mstart;
echo "
Department Locations:
";
$query="SELECT dlocation FROM dept_locations where dnumber=$dno";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$dloc=mysql_result($result,$i,"dlocation");
echo $dloc, "
\n";
$i++;
}
echo "Employees:
";
$query="SELECT ssn,lname,fname FROM employee where dno=$dno";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
Employee SSN |
Last Name |
First Name |
$i=0;
while ($i < $num) {
$essn=mysql_result($result,$i,"ssn");
$elname=mysql_result($result,$i,"lname");
$efname=mysql_result($result,$i,"fname");
?>
echo $essn; ?> |
echo $elname; ?> |
echo $efname; ?> |
$i++;
}
?>
echo "Projects:
";
$query="SELECT pnumber,pname,plocation FROM project where dnum=$dno";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
Project Number |
Project Name |
Location |
$i=0;
while ($i < $num) {
$pnum=mysql_result($result,$i,"pnumber");
$pname=mysql_result($result,$i,"pname");
$ploc=mysql_result($result,$i,"plocation");
?>
echo $pnum; ?> |
echo $pname; ?> |
echo $ploc; ?> |
$i++;
}
mysql_close();
?>
Return to main page