-
Notifications
You must be signed in to change notification settings - Fork 1
/
AdminUpdateItem.php
50 lines (30 loc) · 1.39 KB
/
AdminUpdateItem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php include('header1.php');?>
<html>
</head>
<body>
<?php
include "conn.php"; // Using database connection file here
$id = $_GET['id']; // get id through query string
$query = mysqli_query($conn,"select * from products where ProductID='$id'"); // select query
$row = mysqli_fetch_array($query); // fetch data
if(isset($_POST['Update'])) // when click on Update button
{
$ProductName = $_POST['ProductName'];
$ProductPrice = $_POST['ProductPrice'];
$ProductCategoryID = $_POST['ProductCategoryID'];
$query=mysqli_query($conn," UPDATE `products` SET ProductName='$ProductName', ProductPrice='$ProductPrice', ProductCategoryID='$ProductCategoryID' WHERE ProductID='$id'");
if($query){
echo '<script>window.location.href = "AdminManageItem.php";</script>';
}else{
echo "Error".$sql."".mysqli_error($conn);
}
// redirects to all records page
}
?>
<h3>Update Data</h3>
<form method="POST">
<input type="text" name="ProductName" value="<?php echo $row['ProductName'] ?>" placeholder="Enter Name" Required>
<input type="text" name="ProductPrice" value="<?php echo $row['ProductPrice'] ?>" placeholder="Enter Price" Required>
<input type="text" name="ProductCategoryID" value="<?php echo $row['ProductCategoryID'] ?>" placeholder="Enter Ctegory ID" Required>
<input type="submit" name="Update" value="Update">
</form>