Web
Web
Câu 1
+themdcl.php
<html>
<body>
</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"];
if($connect->query($sql)==true)
else
$connect->close();
}
?>
Câu 2
+themcd.php
<html>
<body>
<?php
$row["madiemcachly"] ."'>" .
$row["tendiemcachly"] .
"</option>";
?>
</select>
</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'];
echo $sql;
if($connect->query($sql)==true)
else
$connect->close();
?>
Câu 3
+ lietkecd.php
<html>
<body>
<table>
<tr>
<th>STT</th>
<th>Gioi Tinh</th>
<th>Nam Sinh</th>
<th>Nuoc Ve</th>
<th>Chuc Nang</th>
</tr>
<?php
$i = 0;
while($row = mysqli_fetch_assoc($result)){
$i++;
$gioitinh;
if($row['GioiTinh'] == 1){
$gioitinh = 'nam';
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);
$("#row-"+MaCD).remove();
console.log(data);
});
});
});
</script>
+ xoacd.php
<?php
$id = $_GET['id'];
echo $sql;
if($connect->query($sql)==true)
else
$connect->close();
?>
Câu 4
+ chitiet.php
<?php
$id = $_GET['id'];
$row = mysqli_fetch_assoc($result)
?>
<html>
<body>
Ten cong dan <input type="text" name="txtTenCD" value = "<?php echo $row['TenCongDan']?
>"><br>
<?php
$selected = "selected";
else
$selected = "";
$rowDCL["madiemcachly"] .
"'$selected>" .
$rowDCL["tendiemcachly"] .
"</option>";
?>
</select>
</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'];
echo $sql;
if($connect->query($sql)==true)
else
$connect->close();
}
?>
Câu 5
+ lietkec.php
<html>
<body>
<?php
$row["madiemcachly"] ."'>" .
$row["tendiemcachly"] .
"</option>";
?>
</select><br>
</select>
<div >
<table id="result">
<tr>
<th>STT</th>
</tr>
</table>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$("#DCL").change(function(){
$("#BN").empty();
var MaDCL=$(this).val();
});
});
$("#BN").change(function(){
$(".result").remove();
var Mabn=$(this).val();
console.log(obj[0]);
$("#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'];
if($connect->query($sql)==true){
$i = 0;
while($row = mysqli_fetch_array($result))
{
$data[$i]["mabn"] = $row["MaCongDan"];
$data[$i]["tenbn"] = $row["TenCongDan"];
$i++;
}
echo json_encode($data);
}
else
$connect->close();
?>
+ timtc.php
<?php
$id = $_GET['id'];
if($connect->query($sql)==true){
$i = 0;
while($row = mysqli_fetch_array($result))
{
$data[$i]["matc"] = $row["MaTrieuChung"];
$data[$i]["tentc"] = $row["TenTrieuChung"];
$i++;
echo json_encode($data);
else
$connect->close();
?>