-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateexistingindex.php
58 lines (43 loc) · 1.6 KB
/
updateexistingindex.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
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<?php include "config.php"?>
<html>
<head>
<title>Update</title>
<link rel="stylesheet" type="text/css" href="flatly.css">
</head>
<body>
<?php
include "config.php";
// Check connection
if(isset($_POST['submit'])){
$drugcode = $_POST['drugcode'];
$drugname = $_POST['drugname'];
$qty = $_POST['qty'];
$batchno = $_POST['batchno'];
$expirydate = $_POST['expirydate'];
$price = $_POST['price'];
$vat = $_POST['vat'];
$total = $_POST['total'];
$sql = "SELECT drugname FROM medicine WHERE drugcode = '$drugcode'";
$result = $mysqli->query($sql);
if ($result->num_rows > 0){
$sql = "UPDATE medicine SET drugname = '$drugname', qty = '$qty', batchno ='$batchno', expirydate ='$expirydate', price ='$price', vat = '$vat', total ='$total' WHERE drugcode= '$drugcode'";
if(mysqli_query($mysqli, $sql)){
echo "<div class='alert alert-dismissible alert-primary'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<p class='mb-0'>Entry for Drugcode : $drugcode , Submitted successfully <a href='updateexisting.php' class='alert-link'>Want Order More?</a>.</p>
</div>";
}else{
echo "Error updating record: " . $mysqli->error;
}
}else{
echo "<div class='alert alert-dismissible alert-warning'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>Warning!</h4>
<p class='mb-0'>Drugcode : $drugcode , No such stock... <a href='orderstock.php' class='alert-link'>Want Order?</a>.</p>
</div>";
}
}
?>
</body>
</html>