Basic Data Management

<html>

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="../style.css">

<style>

    .fileUpload{                    

width: 30%;                

height: 40px;                  

background-color: rgb(29, 4, 255);                  

text-align: center;                

color: #f2f2f2;                

border-top: 5px solid red;                  

border-right: 2px solid red;                    

border-left: 2px solid red;                

font-size: larger;                  

font-family: Phetsarath OT;                

}                  

input[type="file"]                  

{                  

display: none;                  

}                  

.fileUpload input.upload                    

{                  

display: inline-block;                  

}  

</style>

</head>

<body>

   

<?php

include('../DBC.php');

$dd = $_GET['Edit'];


    $sql = "select * from product where ID = '$dd'";

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

    if($query){

        if($row=mysqli_fetch_assoc($query)){

        ?>

<div class="banner">                    

<h2 style="font-family: Phetsarath OT;">ສິນຄ້າ</h2>                

</div>                  

<div class="container">                

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

               

<div class="row">                  

<div class="col-25">                    

<label for="ID">ລະຫັດ</label>                  

</div>                  

<div class="col-75">                    

<input type="text" id="t1" name="t1" value="<?php echo $row['ID'];?>">                  

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ຊື່</label>                

</div>                  

<div class="col-75">                    

<input type="text" id="t2" name="t2" value="<?php echo $row['Name'];?>">                    

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ປະເພດ</label>                  

</div>                  

<div class="col-75">                    

<input type="text" id="t3" name="t3" value="<?php echo $row['Cat'];?>">                

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ຫົວໜ່ວຍ</label>                

</div>                  

<div class="col-75">                    

<input type="text" id="t4" name="t4" value="<?php echo $row['Detail'];?>">                  

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ລາຄາຊື້</label>                

</div>                  

<div class="col-75">                    

<input type="text" id="t5" name="t5" value="<?php echo $row['Pricein'];?>">                

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ລາຄາຂາຍ</label>                

</div>                  

<div class="col-75">                    

<input type="text" id="t6" name="t6" value="<?php echo $row['Priceout'];?>">                    

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ຈໍານວນ</label>                  

</div>                  

<div class="col-75">                    

<input type="text" id="t7" name="t7" value="<?php echo $row['Amount'];?>">                  

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="ID">ຮູບພາບ</label>                  

</div>                  

<div class="col-75">                    

<input type="text" id="t8" name="t8" value="<?php echo $row['Picture'];?>">                

</div>                  

</div>

<div class="row">                  

<div class="col-25">                    

<label for="name">ຮູບພາບ</label>                    

</div>                  

<div class="col-75">                    

<div class="fileUpload">                    

<label class="upload" style="padding: 0px;">                    

<input name="choosefile" type="file"/>                  

ເລືອກຮູບພາບ                

</label>                    

</div>                  

</div>                  

</div>                  

<br>                    

<div class="row">                  

<input type="submit" value="ແກ້ໄຂ" name="update">                  

</div>


<?php

        }

?>

    </form></div>

    <?php  

    /*

    try{

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

        $t1=$_POST['t1'];

        $t2=$_POST['t2'];

        $t3=$_POST['t3'];

        $t4=$_POST['t4'];

        $t5=$_POST['t5'];

        $t6=$_POST['t6'];

        $t7=$_POST['t7'];

        $filename = $_FILES["choosefile"]["name"];

        $tempname = $_FILES["choosefile"]["tmp_name"];  

            $folder = "image/".$filename;

  // $sq ="update supplier set Tel = '$_POST[u1]', Company = '$_POST[u2]' where ID = '$pp1' ";

  $query1 = mysqli_query($con, "update supplier set ID = '$t1', Name = '$t2', Cat = '$t3', Unit = '$t4', Pricein = '$t5', Priceout = '$t6', Amount = '$t7', Picture = 'choosefile' where ID = '$t1' ");

if($query1){

   header("refresh:0; ../Supplier.php");

       }

       else{echo'Not Update';}

//echo $pp1, $pp2;

}

    }

    catch(Exception $ex){}

    }


}

*/

    }


?>

   

</body>

</html>    


<?php

$msg = "";

// check if the user has clicked the button "UPLOAD"

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

    $t1 = $_POST['t1'];

    $t2 = $_POST['t2'];

    $t3 = $_POST['t3'];

    $t4 = $_POST['t4'];

    $t5 = $_POST['t5'];

    $t6 = $_POST['t6'];

    $t7 = $_POST['t7'];

    $t8 = $_POST['t8'];

    $filename = $_FILES["choosefile"]["name"];

    $tempname = $_FILES["choosefile"]["tmp_name"];  

    $folder = "image/".$filename;

    if($tempname != "")

        {

    move_uploaded_file($tempname, $folder);

            $update="update product set Name='$t2', Cat='$t3', Detail='$t4', Pricein= '$t5', Priceout= '$t6', Amount= '$t7', Picture= '$filename'

             where ID='$t1'";  

        }else

        {

            $update="update product set Name='$t2', Cat='$t3', Detail='$t4', Pricein= '$t5', Priceout= '$t6', Amount= '$t7', Picture= '$t8'

             where ID='$t1'";  

        }

       

        $query1=mysqli_query($con, $update);

        if($query1){

            header("refresh:0; ../Product.php");

                }

                else{echo'Not Update';}

         //echo $pp1, $pp2;

         

       

}

?>