Project – Databases
The purpose of this project was the development of an application capable of managing the patients in a hospital. Only a part of the project is presented.
-
<?php
-
print("<html>".
-
"<head>".
-
"<title>MedArt</head>".
-
"<head>".
-
"<body>".
-
"<p>Add a new department:</p>".
-
"<form action=\"insertDepartmentList.php\" method=\"post\"".
-
"<p>Department id:</p>".
-
"<input type=\"text\" name=\"department_id\"/>".
-
"<p>Tile :</p>".
-
"<input type=\"text\" name=\"title\"/>".
-
"<p>Hospital</p>".
-
"<input type=\"text\" name=\"hospital_id\"/><br>".
-
"<input type=\"reset\",name=\"clear\",value=\"Clear\">".
-
"<input type=\"submit\",name=\"request\",value=\"Add\">".
-
"</body>".
-
"</html>");
-
?>
-
<?php
-
echo "<html>";
-
echo "<head>";
-
echo "<title>MedArt</head>";
-
echo "<head>";
-
echo "<body>";
-
echo "<p>Add a new entry:</p>";
-
echo "<form action=\"insertDoctorList.php\" method=\"post\"";
-
echo "<p>Doctor id:</p>";
-
echo "<input type=\"text\" name=\"doctor_id\"/>";
-
echo "<p>Name:</p>";
-
echo "<input type=\"text\" name=\"name\"/>";
-
echo "<p>Surname</p>";
-
echo "<input type=\"text\" name=\"surname\"/>";
-
echo "<p>Speciality</p>";
-
echo "<input type=\"text\" name=\"speciality_id\"/><br>";
-
-
echo "<input type=\"reset\",name=\"clear\",value=\"Clear\">";
-
echo "<input type=\"submit\",name=\"request\",value=\"Add\">";
-
echo "</body>";
-
echo "</html>";
-
?>
-
<?php
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Could not connect to the database!\n";
-
exit;
-
}
-
$department_id=htmlspecialchars($_POST['department_id']);
-
$title=htmlspecialchars($_POST['title']);
-
$hospital_id=htmlspecialchars($_POST['hospital_id']);
-
-
$sql_query="insert into departmentList (department_id,title,hospital_id) values('$department_id','$title','$hospital_id');";
-
odbc_exec($db,$sql_query) or die("Cannot execute the insert query !");
-
odbc_close($db);
-
-
//redirect
-
$to = 'viewDepartmentList.php';
-
header('Location: '. $to);
-
?>
-
<?php
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Could not connect to the database!\n";
-
exit;
-
}
-
$doctor_id=htmlspecialchars($_POST['doctor_id']);
-
$name=htmlspecialchars($_POST['name']);
-
$surname=htmlspecialchars($_POST['surname']);
-
$speciality_id=htmlspecialchars($_POST['speciality_id']);
-
-
$sql_query="insert into doctorList (doctor_id,name,surname,speciality_id) values('$doctor_id','$name','$surname','$speciality_id');";
-
//$sql_query="select * from doctorList;";
-
odbc_exec($db,$sql_query) or die("Cannot execute the insert query !");
-
odbc_close($db);
-
-
//redirect
-
$to = 'viewDoctorList.php';
-
header('Location: '. $to);
-
?>
-
<?php
-
//conect to the database
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Cannot connect to the database !\n";
-
exit;
-
}
-
-
$sql_query="select * from departmentList";
-
$process=odbc_exec($db,$sql_query) or die("Unable to process the query");
-
echo "<p align=\"center\"><b><font size=\"4\">Department list</font></b></p>";
-
echo "<div align=\"center\">".
-
"<table border=\"1\" width=\"50%\" id=\"departmentTable\">".
-
"<tr><th>Department Id</th>".
-
"<th>Title</th>".
-
"<th>Hospital</th>";
-
while(odbc_fetch_row($process) )
-
{
-
$id=odbc_result($process,"department_id");
-
$name=odbc_result($process,"title");
-
$surname=odbc_result($process,"hospital_id");
-
printf("<tr><td><p align=\"center\">%s</p></td><td>".
-
"<p align=\"center\">%s</p></td><td>".
-
"<p align=\"center\">%s</p></td>",$department_id,$title,$hospital_id);
-
}
-
echo "</table></div>";
-
-
odbc_close($db);
-
?>
-
<?php
-
//conect to the database
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Cannot connect to the database !\n";
-
exit;
-
}
-
-
$sql_query="select * from districtList";
-
$process=odbc_exec($db,$sql_query) or die("Unable to process the query");
-
echo "<p align=\"center\"><b><font size=\"4\">District list</font></b></p>";
-
echo "<div align=\"center\">".
-
"<table border=\"1\" width=\"50%\" id=\"districtTable\">".
-
"<tr><th>District Id</th>".
-
"<th>Name</th></tr>";
-
while(odbc_fetch_row($process) )
-
{
-
$district_id=odbc_result($process,"district_id");
-
$name=odbc_result($process,"name");
-
printf("<tr><td><p align=\"center\">%s</p></td><td>".
-
"<p align=\"center\">%s</p></td><td></tr>",$district_id,$name);
-
}
-
echo "</table></div>";
-
-
odbc_close($db);
-
?>
-
<?php
-
//conect to the database
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Cannot connect to the database !\n";
-
exit;
-
}
-
-
$sql_query="select * from doctorList";
-
$process=odbc_exec($db,$sql_query) or die("Unable to process the query");
-
echo "<p align=\"center\"><b><font size=\"4\">Doctors list</font></b></p>";
-
echo "<div align=\"center\">".
-
"<table border=\"1\" width=\"50%\" id=\"doctorsTable\">".
-
"<tr><th>Doctor Id</th>".
-
"<th>Name</th>".
-
"<th>Surname</th>".
-
"<th>Speciality</th></tr>";
-
while(odbc_fetch_row($process) )
-
{
-
$id=odbc_result($process,"doctor_id");
-
$name=odbc_result($process,"name");
-
$surname=odbc_result($process,"surname");
-
$speciality=odbc_result($process,"speciality_id");
-
printf("<tr><td><p align=\"center\">%s</p></td><td><p align=\"center\">%s</p></td><td><p align=\"center\">%s</p></td><td><p align=\"center\">%s</p></td></tr>",$id,$name,$surname,$speciality);
-
}
-
echo "</table></div>";
-
-
odbc_close($db);
-
?>
-
<?php
-
//conect to the database
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Cannot connect to the database !\n";
-
exit;
-
}
-
-
$sql_query="select * from hospitalList";
-
$process=odbc_exec($db,$sql_query) or die("Unable to process the query");
-
echo "<p align=\"center\"><b><font size=\"4\">Hostpital list</font></b></p>";
-
echo "<div align=\"center\">".
-
"<table border=\"1\" width=\"50%\" id=\"hostpitalTable\">".
-
"<tr><th>Hospital Id</th>".
-
"<th>Title</th>".
-
"<th>District</th>".
-
"<th>Place</th>";
-
while(odbc_fetch_row($process) )
-
{
-
$hostpital_id=odbc_result($process,"hostpital_id");
-
$title=odbc_result($process,"title");
-
$district_id=odbc_result($process,"district_id");
-
$place_id=odbc_result($process,"place_id");
-
printf("<tr><td><p align=\"center\">%s</p></td><td>".
-
"<p align=\"center\">%s</p></td><td>".
-
"<p align=\"center\">%s</p></td>".
-
"<p align=\"center\">%s</p></td>",$hostpital_id,$title,$district_id,$palce_id);
-
}
-
echo "</table></div>";
-
-
odbc_close($db);
-
?>
-
<?php
-
//conect to the database
-
$server="medartserver";
-
$user="";
-
$password="";
-
if(!($db=odbc_connect($server,$user,$password)))
-
{
-
echo "Cannot connect to the database !\n";
-
exit;
-
}
-
-
$sql_query="select place_id, placeList.name as name, districtList.name as district_name, region ".
-
"from placeList join districtList on (placeList.district_id=districtList.district_id) ".
-
" order by place_id" ;
-
-
$process=odbc_exec($db,$sql_query) or die("Unable to process the query");
-
echo "<p align=\"center\"><b><font size=\"4\">Place list</font></b></p>";
-
echo "<div align=\"center\">".
-
"<table border=\"1\" width=\"50%\" id=\"placeTable\">".
-
"<tr><th>Place Id</th>".
-
"<th>Name</th>".
-
"<th>District</th>".
-
"<th>Region</th></tr>";
-
while(odbc_fetch_row($process) )
-
{
-
$place_id=odbc_result($process,"place_id");
-
$name=odbc_result($process,"name");
-
$district_id=odbc_result($process,"district_name");
-
$region=odbc_result($process,"region");
-
printf("<tr><td><p align=\"center\">%s</p></td>".
-
"<td><p align=\"center\">%s</p></td>".
-
"<td><p align=\"center\">%s</p></td>".
-
"<td><p align=\"center\">%s</p></td></tr>",$place_id,$name,$district_id,$region);
-
}
-
echo "</table></div>";
-
odbc_close($db);
-
?>