-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewcategory.php
137 lines (122 loc) · 3.2 KB
/
viewcategory.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
<?php
include("header.php");
include("dbconnection.php");
if(!isset($_SESSION['adminid']))
{
echo "<script>window.location='adminloginpanel.php'; </script>";
}
if(isset($_GET['deleteid']))
{
$sql = "DELETE FROM category WHERE category_id='$_GET[deleteid]'";
if(!mysqli_query($con,$sql))
{
echo "<script>alert('Failed to delete record'); </script>";
}
else
{
if(mysqli_affected_rows($con) >= 1)
{
echo "<script>alert('This record deleted successfully..'); </script>";
}
}
}
?>
<main id="main">
<!-- ======= Cta Section ======= -->
<section id="cta" class="cta">
<div class="container">
<div class="text-center" data-aos="zoom-in">
<br><br>
<h3><?php
if($_GET['cattype']=="Produce")
{
echo "Produce Category";
}
else
{
echo "Product Category";
}
?></h3>
</div>
</div>
</section><!-- End Cta Section -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact">
<div class="container">
<div class="row">
<div class="col-lg-12" data-aos="fade-up" data-aos-delay="100">
<div class="info mt-4 ">
<center><h4> <?php
if($_GET['cattype']=="Produce")
{
echo "View or Delete Produce Category";
}
else
{
echo "View or Delete Product Category";
}
?></h4></center><hr>
<?php
$sql = "SELECT * FROM category where category_type='$_GET[cattype]'";
$qsql = mysqli_query($con,$sql);
if(mysqli_num_rows($qsql) == 0)
{
echo "<center>There is no category to display!!</center>";
}
else
{
?>
<table ID="datatable" class="table table-striped table-bordered " >
<thead>
<tr>
<th height="38"><strong>Category</strong></th>
<th><strong>Description</strong></th>
<th><strong>Image</strong></th>
<th><strong>Status</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php
while($rs = mysqli_fetch_array($qsql))
{
echo "
<tr>
<td> $rs[category]</td>
<td> $rs[description]</td>
<td>
<img src='imgcategory/$rs[img]' width='25' height='25'>
</td>
<td> $rs[status]</td>
<td> <a href='category.php?editid=$rs[category_id]&cattype=$rs[category_type]&cattype=$_GET[cattype]' CLASS='btn btn-info'>Edit</a>
<a href='viewcategory.php?deleteid=$rs[category_id]&cattype=$_GET[cattype]' onclick='return delconfirm()' CLASS='btn btn-danger'>Delete</a></td>
</tr>";
}
?>
</tbody>
</table>
<?php
}
?>
</div>
</div>
</div>
</div>
</section><!-- End Contact Section -->
</main><!-- End #main -->
<?php
include("footer.php");
?>
<script type="application/javascript">
function delconfirm()
{
if(confirm("Are you sure you want to delete this record?") == true)
{
return true;
}
else
{
return false;
}
}
</script>