-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_edit.php
176 lines (120 loc) · 5.25 KB
/
item_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
session_start();
if(isset($_SESSION['login_user']) && $_SESSION['login_user']["role"]=="admin"){
include 'db_connect.php';
require 'backend_header.php';
$id = $_GET['id'];
$sql = "SELECT * FROM items where id=:id";
$stmt=$pdo->prepare($sql);
$stmt->bindParam(':id',$id);
$stmt->execute();
$row=$stmt->fetch();
?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Items</h1>
</div>
<div class="row">
<div class="col-md-10 mx-auto">
<div class="card shadow">
<div class="card-header text-primary font-weight-bold">
Edit Items
</div>
<div class="card-body">
<form action="item_update.php" method="post" enctype="multipart/form-data">
<div class="row form-group">
<div class="col-md-2 mx-auto ">
<label>Photo:</label>
</div>
<div class="col-md-8 mx-auto">
<div class="text-center">
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Old Photo</a>
<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">New Photo</a>
</div>
</nav>
</div>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">
<img src="<?php echo $row['photo']?>" class="img-fluid" width="120px">
</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<input type="hidden" name="oldphoto" value="<?php echo $row['photo']?>">
<input type="hidden" name="id" value="<?php echo $row['id']?>">
<input type="file" name="newphoto" class="form-control-file">
</div>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-2 mx-auto ">
<label>Name:</label>
</div>
<div class="col-md-8 mx-auto">
<input type="text" name="name" class="form-control d-inline" value="<?php echo $row['name'] ?>">
</div>
</div>
<div class="row form-group">
<div class="col-md-2 mx-auto ">
<label>Price:</label>
</div>
<div class="col-md-8 mx-auto">
<input type="number" name="price" class="form-control d-inline" value="<?php echo $row['price'] ?>">
</div>
</div>
<div class="row form-group">
<div class="col-md-2 mx-auto ">
<label>Category:</label>
</div>
<div class="col-md-8 mx-auto">
<select class="form-control" name="category">
<?php
$ids=$row['category_id'];
echo $ids;
$sql = "SELECT * FROM categories ";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach($rows as $categories)
{
$id = $categories['id'];
$name = $categories['name'];
?>
<option value="<?php echo $id ?>" <?php if($ids==$id){ ?> selected <?php } ?>><?php echo $name ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="row form-group">
<div class="col-md-2 mx-auto ">
<label>Description:</label>
</div>
<div class="col-md-8 mx-auto">
<textarea class="form-control" name="desc">
<?php echo $row['description']?>
</textarea>
</div>
</div>
<div class="row form-group">
<div class="col-md-6 offset-4">
<button class="btn btn-success float-right">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
require 'backend_footer.php';
}
else{
?>
<h1>
404 error not fonund
</h1>
<?php
}
?>