-
Notifications
You must be signed in to change notification settings - Fork 0
/
Editsubcategory.php
201 lines (177 loc) · 5.63 KB
/
Editsubcategory.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
include('constant.php');
if(isset($_GET['id']))
{
$id = $_GET['id'];
$sql = "SELECT * FROM tbl_subcategory WHERE id=$id";
$res = mysqli_query($con, $sql);
if($res==true)
{
$row = mysqli_fetch_assoc($res);
$category_name = $row['category_name'];
$subcategory_name = $row['subcategory_name'];
$Active = $row['Active'];
}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Brilliance GPS Tracking</title>
<!-- slider start -->
<!-- slider end -->
<link rel="stylesheet" href="css/style.css">
<!-- Menu start --------------->
<link href="menu/quickmenu0.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="menu/quickmenu0.js"></script>
<!-- Menu End --------------->
</head>
<body>
<header>
<div id="wrap">
<div class="logo"><img src="images/logo.png" border="0"></div>
<div class="topmenu">
<ul>
<li><a> </a></li>
<li><a href="change-password.php">Change Password</a> |</li>
<li><a href="index.php"><img src="images/logout.png" width="16" height="16" border="0" align="absmiddle"> Logout</a></li>
</ul>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</header>
<nav>
<ul id="qm0" class="qmmc" >
<li><a href="admin.php">Dashboard</a></li>
<li><a href="#">Product</a>
<ul>
<li><a href="add-category.php">Add Category</a></li>
<li><a href="add-sub-category.php">Add Sub Category</a></li>
<li><a href="product.php">Add Product</a></li>
</ul>
</li>
</ul>
</nav>
<div id="wrap">
<div class="clear" style="height:5px;"></div>
<div id="wrap2">
<h1>Add Sub Category</h1>
<br>
<form action="" method="POST" enctype="multipart/form-data">
<div class="form-raw">
<div class="form-name">Select Category</div>
<div class="form-txtfld">
<select name="category_name">
<option>Select Option</option>
<?php
$sql = "SELECT * FROM tbl_category2";
$res = mysqli_query($con, $sql);
if($res==true)
{
$count_rows = mysqli_num_rows($res);
if($count_rows>0)
{
while($row=mysqli_fetch_assoc($res))
{
$id_db = $row['id'];
$category_name = $row['category_name'];
?>
<option <?php if($id_db==$id){echo "selected='selected'";} ?> value="<?php echo $category_name; ?>"><?php echo $category_name; ?></option>
<?php
}
}
else
{
?>
<option <?php if($category_name=0){echo "selected='selected'";} ?> value="0">None</option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="clear"></div>
<div class="form-raw">
<div class="form-name">Add Sub Category</div>
<div class="form-txtfld">
<input type="text" name="subcategory_name" value="<?php echo $subcategory_name; ?>">
</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="form-raw">
<div class="form-name">Active</div>
<div class="form-txtfld">
<input <?php if($Active=="Active"){echo "Checked";} ?> type="checkbox" name="Active" value="Active"> Active
</div>
<div class="clear"></div>
</div>
<div class="form-raw">
<div class="form-name"> </div>
<div class="form-txtfld" style="width:290px;">
<input type="submit" name="Submit" class="btn" value="Submit">
</div>
</div>
</div>
</form>
<div class="clear"> </div>
</div>
<div class="form-raw">
<div class="form-name"> </div>
<div class="form-txtfld" style="width:290px;">
</div>
</div>
</div>
<div class="clear"> </div>
</div>
<div class="clear"> </div>
</div>
<div class="clear"></div>
<footer>
<footer class="whitefoter">
<div class="whitefooter-cont">
<div style="float:left;">Copyright © Brilliance GPS Tracking. All Rights Reserved.</div>
<a href="https://www.akswebsoft.com/" target="_blank" style="float:right;">
<img src="images/akslogo.png" alt="AKS Websoft Consulting Pvt. Ltd." title="AKS Websoft Consulting Pvt. Ltd."></a>
<div class="clear"></div>
</div>
</footer>
</footer>
</body>
</php>
<?php
if(isset($_POST['Submit']))
{
$id = $_GET['id'];
$category_name = $_POST['category_name'];
$subcategory_name = $_POST['subcategory_name'];
if(isset($_POST['Active']))
{
$Active = $_POST['Active'];
}
else
{
$Active = "";
}
$sql = "UPDATE tbl_subcategory SET
category_name = '$category_name',
subcategory_name = '$subcategory_name',
Active = '$Active'
WHERE id = $id
";
$res = mysqli_query($con, $sql);
if($res==true)
{
header('location:add-sub-category.php');
}
else
{
header('location:add-sub-category.php');
}
}
?>