0% found this document useful (0 votes)
8 views3 pages

Giaide 1

The document contains multiple HTML forms for managing school and student data, including adding schools, classes, searching for students, and deleting students. Each form interacts with a database using PHP to execute SQL queries based on user input. It includes error handling and feedback for successful or unsuccessful operations.

Uploaded by

Cason mayin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Giaide 1

The document contains multiple HTML forms for managing school and student data, including adding schools, classes, searching for students, and deleting students. Each form interacts with a database using PHP to execute SQL queries based on user input. It includes error handling and feedback for successful or unsuccessful operations.

Uploaded by

Cason mayin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

-- Cau 1: -->

<body>
<form method="GET">
<input type="text" name="matruong">
<input type="text" name="tentruong">
<input type="text" name="diachi">
<input type="Submit" name="Submit" value="Them">
<input type="Reset" name="Reset" value="Reset">

<?<php>
if( isset($__GET['Submit']) && ($__GET['Submit'] == "Them") )
{
include "connect.php";
$matruong = $__GET['matruong'];
$tentruong = $__GET['tentruong'];
$diachi = $__GET['diachi'];
$str = "Insert into TRUONG values('$matruong','$tentruong','$diachi')";
$connect -> query($str);

}
?>

</form>
</body>

<!-- Cau 2: -->


<body>
<form method="GET">
<?<php>
include "connect.php";
$sql ="select * from TRUONG";
$results = $connect -> query($sql);
echo "<select name="matruong">";
while($rows = $results -> fetch_row())
{
echo "<option value="rows[0]">$rows[1]</option>"
}
echo "</select>"

?>
<input type="text" name="malop">
<input type="text" name="tenlop">

<input type="Submit" name="Submit" value="Them">


<?<php>
if( isset($__GET['Submit']) && ($__GET['Submit'] == "Them") )
{
include "connect.php";
$matruong = $__GET['matruong'];
$malop = $__GET['tentruong'];
$tenlop = $__GET['diachi'];
$str1 = "Insert into LOP values('$matruong','$malop','$tenlop')";
$connect -> query($str);
}
?>
</form>
</body>

<!-- Cau 3: -->


<?<php>
include "connect.php";
$sql ="select * from LOP";
$results = $connect -> query($sql);
echo "<select name="malop">";
while($rows = $results -> fetch_row())
{
echo "<option value="rows[0]">$rows[1]</option>"
}
echo "</select>"

?>
//bo phan ajax

<!-- Cau 4: -->


<body>

<form method="GET">
<input type="text" name="Ten">
<input type= "Submit" name="Submit" value="Tim">
<?<php>
if( isset($__GET['Submit']) && ($__GET['Submit'] == "Tim") )
{
include "connect.php";
$Ten = $__GET['Ten'];
$str = "Select * from HOCSINH where ten = '$Ten' ";
$rs = $connect -> query($str);
if ($rs->num_rows > 0) {
echo "<p>Co</p>"
} else {
echo "<p>Khong</p>";
}

}
?>
</form>
</body>

<!-- Cau 5: -->


<body>

<form method="GET">
<input type="text" name="maso">
<input type= "Submit" name="Submit" value="Xoa">
<?php
if (isset($_GET['Submit']) && ($_GET['Submit'] == "Xoa")) {
include "connect.php";
$Maso = $_GET['maso'];
$str = "SELECT * FROM HOCSINH WHERE maso = '$Maso'";
$rs = $connect->query($str);

if ($rs->num_rows > 0) {
$str2 = "DELETE FROM HOCSINH WHERE maso = '$Maso'";
$connect->query($str2);
echo "<p>Xóa thành công</p>";
} else {
echo "<p>Không tìm thấy</p>";
}
}
?>

</form>
</body>

You might also like