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.

  1. <?php
  2.   print("<html>".
  3.         "<head>".
  4.         "<title>MedArt</head>".
  5.         "<head>".
  6.         "<body>".
  7.         "<p>Add a new department:</p>".
  8.         "<form action=\"insertDepartmentList.php\" method=\"post\"".
  9.         "<p>Department id:</p>".
  10.         "<input type=\"text\" name=\"department_id\"/>".
  11.         "<p>Tile :</p>".
  12.         "<input type=\"text\" name=\"title\"/>".
  13.         "<p>Hospital</p>".
  14.         "<input type=\"text\" name=\"hospital_id\"/><br>".  
  15.         "<input type=\"reset\",name=\"clear\",value=\"Clear\">".
  16.         "<input type=\"submit\",name=\"request\",value=\"Add\">".
  17.         "</body>".
  18.         "</html>");
  19. ?>
  1. <?php
  2.   echo "<html>";
  3.   echo "<head>";
  4.   echo "<title>MedArt</head>";
  5.   echo "<head>";
  6.   echo "<body>";
  7.   echo "<p>Add a new entry:</p>";
  8.   echo "<form action=\"insertDoctorList.php\" method=\"post\"";
  9.   echo "<p>Doctor id:</p>";
  10.   echo "<input type=\"text\" name=\"doctor_id\"/>";
  11.   echo "<p>Name:</p>";
  12.   echo "<input type=\"text\" name=\"name\"/>";
  13.   echo "<p>Surname</p>";
  14.   echo "<input type=\"text\" name=\"surname\"/>";
  15.   echo "<p>Speciality</p>";
  16.   echo "<input type=\"text\" name=\"speciality_id\"/><br>";  
  17.  
  18.   echo "<input type=\"reset\",name=\"clear\",value=\"Clear\">";
  19.   echo "<input type=\"submit\",name=\"request\",value=\"Add\">";
  20.   echo "</body>";
  21.   echo "</html>";
  22. ?>
  1. <?php
  2.   $server="medartserver";
  3.   $user="";
  4.   $password="";
  5.   if(!($db=odbc_connect($server,$user,$password)))
  6.   {
  7.       echo "Could not connect to the database!\n";
  8.       exit;      
  9.   }
  10.   $department_id=htmlspecialchars($_POST['department_id']);
  11.   $title=htmlspecialchars($_POST['title']);
  12.   $hospital_id=htmlspecialchars($_POST['hospital_id']);  
  13.  
  14.   $sql_query="insert into departmentList (department_id,title,hospital_id) values('$department_id','$title','$hospital_id');";
  15.   odbc_exec($db,$sql_query) or die("Cannot execute the insert query !");
  16.   odbc_close($db);
  17.  
  18.   //redirect
  19.   $to = 'viewDepartmentList.php';
  20.   header('Location: '. $to);
  21. ?>
  1. <?php
  2.   $server="medartserver";
  3.   $user="";
  4.   $password="";
  5.   if(!($db=odbc_connect($server,$user,$password)))
  6.   {
  7.       echo "Could not connect to the database!\n";
  8.       exit;      
  9.   }
  10.   $doctor_id=htmlspecialchars($_POST['doctor_id']);
  11.   $name=htmlspecialchars($_POST['name']);
  12.   $surname=htmlspecialchars($_POST['surname']);  
  13.   $speciality_id=htmlspecialchars($_POST['speciality_id']);
  14.  
  15.   $sql_query="insert into doctorList (doctor_id,name,surname,speciality_id) values('$doctor_id','$name','$surname','$speciality_id');";
  16.   //$sql_query="select * from doctorList;";
  17.   odbc_exec($db,$sql_query) or die("Cannot execute the insert query !");
  18.   odbc_close($db);
  19.  
  20.   //redirect
  21.   $to = 'viewDoctorList.php';
  22.   header('Location: '. $to);
  23. ?>
  1. <?php
  2.   //conect to the database
  3.   $server="medartserver";
  4.   $user="";
  5.   $password="";
  6.   if(!($db=odbc_connect($server,$user,$password)))
  7.   {
  8.       echo "Cannot connect to the database !\n";
  9.       exit;
  10.   }
  11.  
  12.   $sql_query="select * from departmentList";
  13.   $process=odbc_exec($db,$sql_query) or die("Unable to process the query");
  14.   echo "<p align=\"center\"><b><font size=\"4\">Department list</font></b></p>";
  15.   echo "<div align=\"center\">".
  16.        "<table border=\"1\" width=\"50%\" id=\"departmentTable\">".
  17.        "<tr><th>Department Id</th>".
  18.        "<th>Title</th>".
  19.        "<th>Hospital</th>";
  20.   while(odbc_fetch_row($process) )
  21.   {
  22.       $id=odbc_result($process,"department_id");
  23.       $name=odbc_result($process,"title");
  24.       $surname=odbc_result($process,"hospital_id");
  25.       printf("<tr><td><p align=\"center\">%s</p></td><td>".
  26.       "<p align=\"center\">%s</p></td><td>".
  27.       "<p align=\"center\">%s</p></td>",$department_id,$title,$hospital_id);
  28.   }
  29.   echo "</table></div>";
  30.  
  31.   odbc_close($db);
  32. ?>
  1. <?php
  2.   //conect to the database
  3.   $server="medartserver";
  4.   $user="";
  5.   $password="";
  6.   if(!($db=odbc_connect($server,$user,$password)))
  7.   {
  8.       echo "Cannot connect to the database !\n";
  9.       exit;
  10.   }
  11.  
  12.   $sql_query="select * from districtList";
  13.   $process=odbc_exec($db,$sql_query) or die("Unable to process the query");
  14.   echo "<p align=\"center\"><b><font size=\"4\">District list</font></b></p>";
  15.   echo "<div align=\"center\">".
  16.        "<table border=\"1\" width=\"50%\" id=\"districtTable\">".
  17.        "<tr><th>District Id</th>".
  18.        "<th>Name</th></tr>";
  19.   while(odbc_fetch_row($process) )
  20.   {
  21.       $district_id=odbc_result($process,"district_id");
  22.       $name=odbc_result($process,"name");
  23.       printf("<tr><td><p align=\"center\">%s</p></td><td>".
  24.       "<p align=\"center\">%s</p></td><td></tr>",$district_id,$name);
  25.   }
  26.   echo "</table></div>";
  27.  
  28.   odbc_close($db);
  29. ?>
  1. <?php
  2.   //conect to the database
  3.   $server="medartserver";
  4.   $user="";
  5.   $password="";
  6.   if(!($db=odbc_connect($server,$user,$password)))
  7.   {
  8.       echo "Cannot connect to the database !\n";
  9.       exit;
  10.   }
  11.  
  12.   $sql_query="select * from doctorList";
  13.   $process=odbc_exec($db,$sql_query) or die("Unable to process the query");
  14.   echo "<p align=\"center\"><b><font size=\"4\">Doctors list</font></b></p>";
  15.   echo "<div align=\"center\">".
  16.        "<table border=\"1\" width=\"50%\" id=\"doctorsTable\">".
  17.        "<tr><th>Doctor Id</th>".
  18.        "<th>Name</th>".
  19.        "<th>Surname</th>".
  20.        "<th>Speciality</th></tr>";
  21.   while(odbc_fetch_row($process) )
  22.   {
  23.       $id=odbc_result($process,"doctor_id");
  24.       $name=odbc_result($process,"name");
  25.       $surname=odbc_result($process,"surname");
  26.       $speciality=odbc_result($process,"speciality_id");
  27.       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);
  28.   }
  29.   echo "</table></div>";
  30.  
  31.   odbc_close($db);
  32. ?>
  1. <?php
  2.   //conect to the database
  3.   $server="medartserver";
  4.   $user="";
  5.   $password="";
  6.   if(!($db=odbc_connect($server,$user,$password)))
  7.   {
  8.       echo "Cannot connect to the database !\n";
  9.       exit;
  10.   }
  11.  
  12.   $sql_query="select * from hospitalList";
  13.   $process=odbc_exec($db,$sql_query) or die("Unable to process the query");
  14.   echo "<p align=\"center\"><b><font size=\"4\">Hostpital list</font></b></p>";
  15.   echo "<div align=\"center\">".
  16.        "<table border=\"1\" width=\"50%\" id=\"hostpitalTable\">".
  17.        "<tr><th>Hospital Id</th>".
  18.        "<th>Title</th>".
  19.        "<th>District</th>".
  20.        "<th>Place</th>";
  21.   while(odbc_fetch_row($process) )
  22.   {
  23.       $hostpital_id=odbc_result($process,"hostpital_id");
  24.       $title=odbc_result($process,"title");
  25.       $district_id=odbc_result($process,"district_id");
  26.       $place_id=odbc_result($process,"place_id");
  27.       printf("<tr><td><p align=\"center\">%s</p></td><td>".
  28.       "<p align=\"center\">%s</p></td><td>".
  29.       "<p align=\"center\">%s</p></td>".
  30.       "<p align=\"center\">%s</p></td>",$hostpital_id,$title,$district_id,$palce_id);
  31.   }
  32.   echo "</table></div>";
  33.  
  34.   odbc_close($db);
  35. ?>
  1. <?php
  2.   //conect to the database
  3.   $server="medartserver";
  4.   $user="";
  5.   $password="";
  6.   if(!($db=odbc_connect($server,$user,$password)))
  7.   {
  8.       echo "Cannot connect to the database !\n";
  9.       exit;
  10.   }
  11.  
  12.   $sql_query="select place_id, placeList.name as name, districtList.name as district_name, region ".
  13.              "from placeList join districtList on (placeList.district_id=districtList.district_id) ".
  14.              " order by place_id" ;
  15.              
  16.   $process=odbc_exec($db,$sql_query) or die("Unable to process the query");
  17.   echo "<p align=\"center\"><b><font size=\"4\">Place list</font></b></p>";
  18.   echo "<div align=\"center\">".
  19.        "<table border=\"1\" width=\"50%\" id=\"placeTable\">".
  20.        "<tr><th>Place Id</th>".
  21.        "<th>Name</th>".
  22.        "<th>District</th>".
  23.        "<th>Region</th></tr>";
  24.   while(odbc_fetch_row($process) )
  25.   {
  26.       $place_id=odbc_result($process,"place_id");
  27.       $name=odbc_result($process,"name");
  28.       $district_id=odbc_result($process,"district_name");
  29.       $region=odbc_result($process,"region");
  30.       printf("<tr><td><p align=\"center\">%s</p></td>".
  31.       "<td><p align=\"center\">%s</p></td>".
  32.       "<td><p align=\"center\">%s</p></td>".
  33.       "<td><p align=\"center\">%s</p></td></tr>",$place_id,$name,$district_id,$region);
  34.   }
  35.   echo "</table></div>";  
  36.   odbc_close($db);
  37. ?>
  1.  
  1.