-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcat_add.php
49 lines (43 loc) · 1.32 KB
/
cat_add.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
<?php
require 'config.php';
$name = $_POST['name'];
$des = $_POST['des'];
$conn = connection();
$check = "SELECT * FROM `category` WHERE `cat_name` = '$name'";
$check = $conn->query($check);
//echo count($check); die;
if ($check->rowCount() > 0) {
echo "<span style='font-size:20px;color:red;' class=\"splash-description\">Category already exist.</span><br>";
$conn=null;
}else{
$sql = "INSERT INTO category (cat_name, cat_des)
VALUES ('$name', '$des')";
$conn->query($sql);
$conn=null;
echo "<span style='font-size:20px;color:green;' class=\"splash-description\">Category added.</span><br>";
}
$conn = connection();
$sql = "select * from category order by cat_name ASC";
$data = $conn->query($sql);
$conn=null;
?>
<table class="table table-condensed table-hover table-bordered table-striped">
<thead>
<tr>
<th><center>S. no.</center></th>
<th><center>Name</center></th>
<th><center>Description</center></th>
<!-- <th><center>Status</center></th> -->
</tr>
</thead>
<tbody style="color:black;">
<?php $s=0;
foreach ($data as $row){ $s++; ?>
<tr>
<td><center><?php echo $s; ?></center></td>
<td><?php echo ucwords($row['cat_name']); ?></td>
<td><?php echo ucwords($row['cat_des']); ?></td>
</tr>
<?php } ?>
</tbody>
</table>