-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproedit.php
167 lines (148 loc) · 7.16 KB
/
proedit.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
<?php
// 数据库连接信息
include ("conn.php");
$id = $_GET["id"];
$sql = "SELECT * FROM product where id = ".$id;
$result = mysqli_query($conn, $sql);
$row = $result->fetch_assoc();
$row["name"] = str_replace('\'', '`', $row["name"]);
$row["description"] = str_replace('\'', '`', $row["description"]);
?>
<!DOCTYPE html>
<html lang="en">
<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">
<!-- 引入样式,mdui -->
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css"/>
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
<title>CAN302 Store Admin| Product</title>
</head>
<body>
<?php include 'include/sidebar.php'; ?>
<!-- 顶部框 -->
<div class="content" id="content" style="mdui-drawer-body-left">
<h1 style="text-transform:capitalize;">Product Management/Edit Product
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-blue-accent" id="return" onclick="<?php echo "location.href='".$_SERVER["HTTP_REFERER"]."'"?>">Return</button>
</h1>
<?php
echo '<form action="editProduct.php?id='.$id.'" method="post" id="submission" enctype="multipart/form-data"></form>'
?>
<h2 style="font-style: italic;">Edit the product information</h2>
<div class="mdui-col-xs-3" style="font-weight: 400;">Product Name:</div>
<div class="mdui-col-xs-9">
<div class="mdui-textfield">
<?php
echo "<input class='mdui-textfield-input' type='text' value='".$row["name"]."' placeholder='Food' form='submission' name='proname'/>";
?>
</div>
</div>
<div class="mdui-col-xs-3">Product Category:</div>
<div class="mdui-col-xs-9">
<select class="mdui-select" form="submission" name="catesele">
<?php
$sql = "SELECT * FROM category";
$rows = mysqli_query($conn, $sql);
while($cate = mysqli_fetch_assoc($rows)){
if ($cate["id"] == $id){
echo "<option value='{$cate["id"]}' selected>{$cate["name"]}</option>";
}else{echo "<option value='{$cate["id"]}'>{$cate["name"]}</option>";}
}
?>
</select>
</div>
<div class="mdui-col-xs-3">Product image:</div>
<div class="mdui-col-xs-9">
<!-- 单选框 -->
<?php
$parh = 'images/product_img/'.$row["id"].'.jpg';
echo'<img src="'.$parh.'" alt="" id="dog" style="width:100px; height: 100px;"><i>Current icon</i><br/>';
?>
<i class="mdui-icon material-icons" style="position:relative; font-size: 100px;" onclick="upload.click()">add_to_photos
<input type="file" form="submission" name="up" id="upload" style="display: none;" accept="image/jpeg"/></i>
<i>Only jpg/png with a maxium size of 500 kb</i>
</div>
<div class="mdui-col-xs-3">Is Hot:</div>
<div class="mdui-col-xs-9">
<select class="mdui-select" form="submission" name="prosele">
<?php
if ($row["is_hot"] == 0){
echo ' <option value="0" selected>no</option>';
echo ' <option value="1">yes</option>';
echo '</select>';
}else{
echo ' <option value="0">no</option>';
echo ' <option value="1" selected>yes</option>';
echo '</select>';
}
?>
</select>
</div>
<div class="mdui-col-xs-3">Status:</div>
<div class="mdui-col-xs-9">
<select class="mdui-select" form="submission" name="status">
<?php
if ($row["status"] == 0){
echo ' <option value="0" selected>Shelved</option>';
echo ' <option value="1">Unshelved</option>';
}else{
echo ' <option value="0">Shelved</option>';
echo ' <option value="1" selected>Unshelved</option>';
}
?>
</select>
</div>
<div class="mdui-col-xs-3">Product Description:</div>
<div class="mdui-col-xs-9">
<div class="mdui-textfield">
<?php
echo '<textarea class="textfield3" placeholder="Description" name="prodesc" cols="30" rows="3" id="prodesc" form="submission"></textarea>';
echo '<script>';
echo 'document.getElementById("prodesc").value="'.$row["description"].'"';
echo '</script>';
?>
</div>
</div>
<div class="mdui-col-xs-3">Product Price:</div>
<div class="mdui-col-xs-9">
<?php
echo "<input type='text' value='{$row["price"]}' form='submission' name='price'>";
?>
</div>
<div class="purchasenumber" >
<div class="mdui-col-xs-3" style="margin-top: 10px;">Quantity in stocks:</div>
<div class="number" >
<i class = "minus iconfont icon-jianhao" class="mdui-col-xs-3" style="margin: 10px 10px 10px 10px;"></i>
<?php
echo "<input type='text' style='margin: 10px 10px 10px -10px;' value='{$row["stock_qty"]}' form='submission' name='quan'>";
?>
<i class = "plus iconfont icon-jiahao1"></i>
</div>
</div>
<div>
<button class="mdui-btn mdui-ripple" id="cancelButton" onclick="cancelEdit()">Resit</button>
<button class="mdui-btn mdui-color-blue-accent mdui-ripple" id="submitButton" form="submission" name="sub">submit</button>
</div>
</div>
</body>
<!-- 这个页面的JS -->
<style>
.side{ padding: 2px 20px;
}
.content{
margin-left: 25px
}
.dog{
position: absolute;
bottom: 0;
}
</style>
<script>
function cancelEdit() {
<?php
echo 'window.location.href = "proedit.php?id='.$row["id"].'"'
?>
}
</script>
</html>