-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcategory.php
152 lines (125 loc) · 5.41 KB
/
category.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
<?php
require_once('include/header.php');
if(!isset($_SESSION['email'])){
header('location: signin.php');
}
?>
<div class="container-fluid mt-2">
<div class="row">
<div class="col-md-3 col-lg-3">
<?php require_once('include/sidebar.php'); ?>
</div>
<?php
if(isset($_GET['del'])){
$del = $_GET['del'];
$query = "DELETE FROM categories WHERE id = $del";
$run = mysqli_query($con,$query);
}
?>
<div class="col-md-9 col-lg-9">
<div class="col-md-9">
<div class="row">
<div class="col-md-1">
<i class="fad fa-th-list fa-6x text-primary"></i>
</div>
<div class="col-md-11 text-left mt-4">
<h1 class="ml-5 display-4 font-weight-normal">View Furniture Categories:</h1>
</div>
</div>
<hr>
<form action="" method="post">
<div class="row">
<?php
if(isset($_POST['submit'])){
$category = $_POST['category'];
$fontawesome = $_POST['fonts'];
$query = "INSERT INTO `categories`(`category`, `fontawesome-icon`) VALUES ('$category',' $fontawesome')";
$run = mysqli_query($con,$query);
}
?>
<div class="col-lg-8">
<div class="row">
<div class="col-lg-6">
<input type="text" name="category" class="form-control" placeholder="Add Category">
</div>
<div class="col-lg-6">
<input type="text" name="fonts" class="form-control" placeholder="Simply Add fa-example ">
</div>
</div>
</div>
<div class="col-lg-4">
<input type="submit" name="submit" class="btn btn-primary" value="Add cat" name="category">
</div><br/>
</div>
</form>
<?php
$r_data = 6;
$pquery = "SELECT * FROM categories";
$prun = mysqli_query($con,$pquery);
$prow = mysqli_num_rows($prun);
$page = ceil($prow / $r_data);
if(isset($_GET['tdata_id'])){
$t_id =$_GET['tdata_id'];
}
else {
$t_id =1;
}
$pro_start = ($t_id - 1) * $r_data;
$query=" SELECT * FROM categories ORDER BY id ASC LIMIT $pro_start,$r_data";
$run = mysqli_query($con,$query);
if(mysqli_num_rows($run) > 0){
?>
<!-- Button to Open the Modal -->
<div class="row mt-5">
<div class="col-md-12 col-lg-12">
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Font Awesome icon</th>
<th>Categories</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($run)){
$id = $row['id'];
$font_awesome = $row['fontawesome-icon'];
$category = ucfirst($row['category']);
?>
<tr>
<td><?php echo $id;?></td>
<td><i class="text-primary <?php echo 'fad '.$font_awesome;?>"></i></td>
<td><?php echo $category;?></td>
<td class="text-center">
<a href="editcat.php?edit=<?php echo $id; ?>"><button type="button" class="btn btn-primary">Edit</button>
</a>
<a href="category.php?del=<?php echo $id;?>"><button class='ml-2 btn btn-danger' value='Delete'>Delete</button></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<ul class="pagination">
<?php for($i=1; $i<= $page; $i++)
{
echo "<li class='page-item ".($t_id == $i ? 'active' : ''). "'><a class='page-link' href='category.php?tdata_id=".$i."'>$i</a></li>";
}
?>
</ul>
</div>
</div>
<?php
}
?>
</div>
</div>
<!---edit category query-->
<!-- Modal -->
</div>
<?php
require_once('include/footer.php');
?>