-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
98 lines (76 loc) · 2.47 KB
/
edit.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
include('config.php');
if (isset($_POST['submit']))
{
$id=$_POST['id'];
$name=mysqli_real_escape_string($db, $_POST['rname']);
$price=mysqli_real_escape_string($db, $_POST['price']);
$quant=mysqli_real_escape_string($db, $_POST['quantity']);
mysqli_query($db,"UPDATE resources SET rname='$name', price='$price' ,quantity='$quant' WHERE product_id='$id'");
header("Location:pharma.php");
}
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{
$id = $_GET['id'];
$result = mysqli_query($db,"SELECT * FROM resources WHERE product_id=".$_GET['id']);
$row = mysqli_fetch_array($result);
if($row)
{
$id = $row['product_id'];
$name = $row['rname'];
$price = $row['price'];
$quant=$row['quantity'];
}
else
{
echo "No results!";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Edit Item</title>
</head>
<body>
<form action="" method="post" action="edit.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<table border="1">
<tr>
<td colspan="2"><b>
<font color='Red'>Edit Records </font>
</b></td>
</tr>
<tr>
<td width="179"><b>
<font>Item Name<em>*</em></font>
</b></td>
<td><label>
<input type="text" name="rname" value="<?php echo $name; ?>" />
</label></td>
</tr>
<tr>
<td width="179"><b>
<font color='#663300'>Price<em>*</em></font>
</b></td>
<td><label>
<input type="text" name="price" value="<?php echo $price ?>" />
</label></td>
</tr>
<tr>
<td width="179"><b>
<font color='#663300'>Quantity<em>*</em></font>
</b></td>
<td><label>
<input type="text" name="quantity" value="<?php echo $quant;?>" />
</label></td>
</tr>
<tr align="Right">
<td colspan="2"><label>
<input type="submit" name="submit" value="Save">
</label></td>
</tr>
</table>
</form>
</body>
</html>