CRUD in general

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<style>

*{

    padding:0px;

    margin:0px;}

body{

    background-color:#FCF;}

input{

        width: 40%;

        height:40px;

        border-radius:15px;

        border-color:#F00;

        margin-left:30%;

        font-family:"Phetsarath OT";

        font-size:18px;

        color:#00C;

        text-align:center;

        }

#option{

    width: 40%;

        height:40px;

        border-radius:15px;

        border-color:#F00;

        margin-left:30%;

        font-family:"Phetsarath OT";

        font-size:18px;

        color:#00C;

        text-align:center;

    }

#bt{

        width: 30%;

        height:50px;

        background-color:#009;

        border-radius:8px;

        border-bottom:5px solid #FFF;

        margin-left:36%;

        font-family:"Phetsarath OT";

        font-size:20px;

        color:#FF0;}

tr{

    border:#F90;}

td{

    font-family:"Phetsarath OT";

    font-family:18px;

    color:#009;}

ol li{

    font-family:"Phetsarath OT";

    font-size:28;

    color:#C00;

    margin-top:20px;

    list-style:none;

    padding-left:8%;

    border:1px;

    background-color:#FC3;

    float:left;}

a{

    text-decoration:none;}

</style>

<title>ລາຍວິຊາ</title>

</head>

<body>

<div style="width:90%; margin-left:5%;"><center><img src="test.jpg" height="150px" width="100%"></center></div>


<?php

include('DBC.php');

?>

<?php

$sq = "SELECT * FROM classroom order by ID";

$cla = $con->query($sq);

?>

<?php

$sql = "SELECT * FROM course";

$course = $con->query($sql);

?>

<div style=" background-color:#0CF; width:90%; margin-left:5%;">

<form action="" method="POST" enctype="multipart/form-data">

<br><input type="text" name="t1" placeholder="ລະຫັດ" value=""><br><br>

<input type="text" name="t2" placeholder="ຊື່ວິຊາ" > <br><br>

<select id="option" required name="t3">

            <option value="" disabled selected>ເລືອກຊັ້ນຮຽນ</option>

           <?php while($row = $cla->fetch_assoc()) { ?>

           <option><?php echo $row['Name'];?></option>

           <?php }?>

  </select><br><br>

<input type="text" name="t4" placeholder="ອາຈານສອນ" > <br><br>

<br>

<input id="bt" type="submit" name="save" value="ເພີ່ມຂໍ້ມູນ"><br>



<?php

try{

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

    $d = $_POST['t1'];

    $n = $_POST['t2'];

    $c = $_POST['t3'];

    $co = $_POST['t4'];


    $sql="insert into Subject (ID, Name, Year, Teacher) values ('$d', '$n', '$c', '$co')";

    mysqli_query($con, $sql);

   

    }

}

catch(Exception $ex){ }

?>

<br>

<center><table border="1" cellpadding="5" cellspacing="0" width="90%" align="center">

  <tr>

    <td style=" background-color:#9FF; text-align:center; font-size:24px; color:red;" width="10%" align="center">ລະຫັດ</td>

    <td style=" background-color:#9FF; font-size:24px; color:red;" align="center" width="25%">ຊື່ລາຍວິຊາ</td>

    <td style=" background-color:#9FF; font-size:24px; color:red;" align="center" width="10%">ຊັ້ນຮຽນ</td>

    <td style=" background-color:#9FF; font-size:24px; color:red;" align="center" width="25%">ອາຈານສອນ</td>

   <td colspan="2" style=" background-color:#9FF; text-align:center; font-size:24px; color:red; width:20%;">ແກ້ໄຂຂໍ້ມູນ</td>

  </tr>

  <?php

  //require_once('DCon.php');

 

  $sql = "select * from subject";

  $query=mysqli_query($con, $sql);

 if($query){

  while ($row_MyRecord = mysqli_fetch_object($query)) { ?>

    <tr>

      <td style="text-align:center;"><?php echo $row_MyRecord->ID?></td>

      <td style="text-align:center;"><?php echo $row_MyRecord->Name?></td>

      <td style="text-align:center;"><?php echo $row_MyRecord->Year?></td>

      <td style="text-align:center;"><?php echo $row_MyRecord->Teacher?></td>

      <td width="5%" style="text-align:center;"><a href="Upsubject.php?Edit=<?php echo $row_MyRecord->ID; ?>">

   ແກ້ໄຂ</a></td>

   <td style="font-weight:300; text-align:center;" width="5%"><a href="Delsubject.php?i=<?php echo $row_MyRecord->ID; ?>">

   ລົບ</a></td>

   

    </tr>

    <?php

   

    }

   

  }?>

</table></center><br><br><br><br>

</form>

</div>

<br><br><a href="MainAdmin.php" target="_self" style="margin-left:10%;"><img src="Arrow2.png" width="170" height="70" alt="Main"></a><a href="index.php" target="_self" style=" float:right; margin-right:10%;"><img src="Arrow1.png" width="170" height="70" alt="Main"></a>

</body>

</html>