0% found this document useful (0 votes)
37 views13 pages

Web

The document contains code for a web application to manage COVID-19 quarantine areas and patients. It includes PHP code to: 1) Add, display, and delete quarantine areas and patients' information stored in a database 2) Show details and update patient information 3) Retrieve and display patients and their symptoms based on selected quarantine area. The code uses HTML, CSS, JavaScript, jQuery, and PHP to build forms, submit data, and make API calls to the backend database.

Uploaded by

Trần Duy Thanh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
37 views13 pages

Web

The document contains code for a web application to manage COVID-19 quarantine areas and patients. It includes PHP code to: 1) Add, display, and delete quarantine areas and patients' information stored in a database 2) Show details and update patient information 3) Retrieve and display patients and their symptoms based on selected quarantine area. The code uses HTML, CSS, JavaScript, jQuery, and PHP to build forms, submit data, and make API calls to the backend database.

Uploaded by

Trần Duy Thanh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 13

Đề 2021 – 2022 HK2

Câu 1

+themdcl.php

<html>

<body>

<form action="themdcl_post.php" method="POST">

Ma diem cach ly <input type="text" name="txtMaDCL" ><br>

Ten diem cach ly <input type="text" name="txtTenDCL" ><br>

Dia chi <input type="text" name="txtDiaChi"><br>

Suc chua <input type="text" name="txtSucChua" ><br>

<input type="submit" name="Submit" value="Thêm">

</form>

</body>

</html>

+themdcl_post.php
<?php

    if(isset($_POST['Submit'])&&($_POST['Submit']=='Thêm'))

  {

        $MADCL = $_POST["txtMaDCL"];

        $TENDCL = $_POST["txtTenDCL"];

        $DIACHI = $_POST['txtDiaChi'];

        $SUCCHUA = $_POST["txtSucChua"];

        $sql = "INSERT INTO DIEMCACHLY VALUES('$MADCL','$TENDCL','$DIACHI', '$SUCCHUA')";

        if($connect->query($sql)==true)

            echo "insert thành công";

        else

            echo "insert không thành công";

        $connect->close();

  }

?>

Câu 2

+themcd.php

<html>

<body>

<form action="themcd_post.php" method="POST">

Ma cong dan <input type="text" name="txtMaCD" ><br>


Ten cong dan <input type="text" name="txtTenCD" ><br>

Gioi tinh<input type="checkbox" name="txtGT" > (Chon tuong ung la nam)<br>

Nam sinh <input type="date" name="txtNamSinh"><br>

Nuoc ve <input type="text" name="txtNuoc" ><br>

Ten diem cach ly <select name="txtDCL" >

<?php

$sql = "SELECT tendiemcachly, madiemcachly FROM diemcachly";

$result = mysqli_query($connect, $sql);

while ($row = mysqli_fetch_assoc($result)) {

echo "<option value='" .

$row["madiemcachly"] ."'>" .

$row["tendiemcachly"] .

"</option>";

?>

</select>

<input type="submit" name="Submit" value="Thêm">

</form>

</body>

</html>

+ themcd_post.php

<?php

if(isset($_POST['Submit'])&&($_POST['Submit']=='Thêm'))

$MACD = $_POST["txtMaCD"];

$TENCD = $_POST["txtTenCD"];

if(isset($_POST['txtGT'])){

$GIOITINH= 1;

}else
{ $GIOITINH=0; }

$NAMSINH = $_POST["txtNamSinh"];

$NUOC = $_POST['txtNuoc'];

$MADCL = $_POST['txtDCL'];

$sql = "INSERT INTO CONGDAN VALUES('$MACD','$TENCD','$GIOITINH', '$NAMSINH', '$NUOC',


'$MADCL')";

echo $sql;

if($connect->query($sql)==true)

echo "insert thành công";

else

echo "insert không thành công";

$connect->close();

?>

Câu 3

+ lietkecd.php

<html>

<body>

<table>

<tr>

<th>STT</th>

<th>Ten Cong Dan</th>

<th>Gioi Tinh</th>
<th>Nam Sinh</th>

<th>Nuoc Ve</th>

<th>Chuc Nang</th>

</tr>

<?php

$sql = "SELECT * FROM CONGDAN";

$result = mysqli_query($connect, $sql);

$i = 0;

while($row = mysqli_fetch_assoc($result)){

$i++;

$gioitinh;

if($row['GioiTinh'] == 1){

$gioitinh = 'nam';

else $gioitinh = 'nu';

echo '

<tr id="row-'.$row['MaCongDan'].'">

<td>'.$i.'</td>

<td>'.$row['TenCongDan'].'</td>

<td>'.$gioitinh.'</td>

<td>'.$row['NamSinh'].'</td>

<td>'.$row['NuocVe'].'</td>

<td>

<a href="chitiet.php?id='.$row['MaCongDan'].'">view</a>

<button id='.$row['MaCongDan'].'>delete</button>

</td>

</tr>';

?>
</table>

</body>

</html>

<script>

$(document).ready(function(){

$("button").click(function(){

var MaCD=$(this).attr('id')

console.log(MaCD);

$.get("xoacd.php?id=" + MaCD, function(data,status){

$("#row-"+MaCD).remove();

console.log(data);

});

});

});

</script>

+ xoacd.php

<?php

$id = $_GET['id'];

$sql = "DELETE FROM CONGDAN WHERE MaCongDan = '$id'";

echo $sql;

if($connect->query($sql)==true)

echo "xoa thành công";

else

echo "xoa không thành công";

$connect->close();

?>

Câu 4
+ chitiet.php

<?php

$id = $_GET['id'];

$sql = "SELECT * FROM CONGDAN WHERE MaCongDan = '$id'";

$result = mysqli_query($connect, $sql);

$row = mysqli_fetch_assoc($result)

?>

<html>

<body>

<form action="capnhatcd.php" method="POST">

Ma cong dan <input type="text" name="txtMaCD" value = "<?php echo $row['MaCongDan']?>"


readonly= "readonly"><br>

Ten cong dan <input type="text" name="txtTenCD" value = "<?php echo $row['TenCongDan']?
>"><br>

Gioi tinh<input type="checkbox" name="txtGT" <?php if($row['GioiTinh'] == 1) echo 'checked'?>>


(Chon tuong ung la nam)<br>

Nam sinh <input type="date" name="txtNamSinh" value = "<?php echo $row['NamSinh']?>"><br>

Nuoc ve <input type="text" name="txtNuoc" value = "<?php echo $row['NuocVe']?>"><br>

Ten diem cach ly <select name="txtDCL" value = "<?php echo $row['MaCongDan']?>">

<?php

$sql = "SELECT tendiemcachly, madiemcachly FROM diemcachly";


$resultDCL = mysqli_query($connect, $sql);

while ($rowDCL = mysqli_fetch_assoc($resultDCL)) {

if(!strcmp($rowDCL['madiemcachly'], $row['MaDiemCachLy'])) //xu ly hien thi diem cach ly cua


benh nhan len truoc

$selected = "selected";

else

$selected = "";

echo "<option value='" .

$rowDCL["madiemcachly"] .

"'$selected>" .

$rowDCL["tendiemcachly"] .

"</option>";

?>

</select>

<input type="submit" name="Submit" value="Update">

</form>

</body>

</html>

+ capnhatcd.php

<?php

    include "../connect.php";

    if(isset($_POST['Submit'])&&($_POST['Submit']=='Update'))

  {

        $MACD = $_POST["txtMaCD"];

        $TENCD = $_POST["txtTenCD"];

        if(isset($_POST['txtGT'])){

            $GIOITINH= 1;

        }else
        {$GIOITINH=0;}

        $NAMSINH = $_POST["txtNamSinh"];

        $NUOC = $_POST['txtNuoc'];

        $MADCL = $_POST['txtDCL'];

        $sql = "UPDATE CONGDAN SET TenCongDan = '$TENCD', GioiTinh = $GIOITINH, NamSinh =


'$NAMSINH', NuocVe = '$NUOC', MaDiemCachLy = '$MADCL' WHERE MaCongDan = '$MACD'";

        echo $sql;

        if($connect->query($sql)==true)

            echo "update thành công";

        else

            echo "update không thành công";

        $connect->close();

  }

?>

Câu 5

+ lietkec.php

<html>

<body>

Ten diem cach ly

<select id = "DCL" name="txtDCL" >


<option value=""selected disabled>Nhấn để chọn</option>

<?php

$sql = "SELECT tendiemcachly, madiemcachly FROM diemcachly";

$result = mysqli_query($connect, $sql);

while ($row = mysqli_fetch_assoc($result)) {

echo "<option value='" .

$row["madiemcachly"] ."'>" .

$row["tendiemcachly"] .

"</option>";

?>

</select><br>

Ten benh nhan <select name="" id="BN">

<option id = "default" value="" selected disabled>Nhấn để chọn</option>

</select>

<div >

<h3>DANH SÁCH CÁC TRIỆU CHỨNG</h3>

<table id="result">

<tr>

<th>STT</th>

<th>Mã triệu chứng</th>

<th>Tên triệu chứng</th>

</tr>

</table>

</div>

</body>

</html>

<script>

$(document).ready(function(){
$("#DCL").change(function(){

$("#BN").empty();

$("#BN").append("<option selected disabled>Nhấn để chọn</option>");

var MaDCL=$(this).val();

$.get("timbn.php?id=" + MaDCL, function(data,status){

var obj = jQuery.parseJSON(data);

for(let i = 0; i < obj.length; i++){

$("#BN").append("<option class = 'bn_result' value= '"+obj[i]['mabn']+"'>"+obj[i]['tenbn']


+"</option>")

});

});

$("#BN").change(function(){

$(".result").remove();

var Mabn=$(this).val();

$.get("timtc.php?id=" + Mabn, function(data,status){

var obj = jQuery.parseJSON(data);

console.log(obj[0]);

for(let i = 0; i < obj.length; i++){

$("#result").append("<tr class='result'>

<td>"+(i+1)+"</td>

<td>"+obj[i]['matc']+"</td>

<td>"+obj[i]['tentc']+"</td>

</tr>")

});

});

});

</script>
+ timbn.php

<?php

    $id = $_GET['id'];

    $sql = "SELECT MaCongDan, TenCongDan FROM CONGDAN WHERE MaDiemCachLy = '$id'";

        if($connect->query($sql)==true){

            $result = mysqli_query($connect, $sql);

            $i = 0;

            while($row = mysqli_fetch_array($result))

      {

             $data[$i]["mabn"] = $row["MaCongDan"];

             $data[$i]["tenbn"] = $row["TenCongDan"];

             $i++;

      }

            echo json_encode($data);

    }

        else

            echo "tim bn không thành công";

        $connect->close();

?>

+ timtc.php

<?php

$id = $_GET['id'];

$sql = "SELECT TC.TenTrieuChung, TC.MaTrieuChung FROM TrieuChung TC, CN_TC WHERE


CN_TC.MaCongDan = '$id' AND TC.MaTrieuChung = CN_TC.MaTrieuChung;";

if($connect->query($sql)==true){

$result = mysqli_query($connect, $sql);

$i = 0;

while($row = mysqli_fetch_array($result))

{
$data[$i]["matc"] = $row["MaTrieuChung"];

$data[$i]["tentc"] = $row["TenTrieuChung"];

$i++;

echo json_encode($data);

else

echo "Tim tc không thành công";

$connect->close();

?>

You might also like