-
Notifications
You must be signed in to change notification settings - Fork 0
/
categories.php
174 lines (154 loc) · 5.54 KB
/
categories.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
<?php
include('../../../wp-config');
?>
<style>
.cover_div {
margin: 50px auto 0;
width: 97%;
}
td>.cat_add_btn{
margin-left:95px;
}
.tr_cvr {
padding: 18px 0 17px;
}
.success_msg {
background: green none repeat scroll 0 0;
float: left;
padding: 10px;
width: 63%;
margin-bottom:10px;
}
.cvr_div {
float: left;
width: 97%;
}
.heading {
float: left;
width: 20%;
}
.add_btn {
float: left;
padding: 12px 0 0;
text-align: right;
width: 47%;
}
.delete_msg {
float: left;
padding: 5px 0 5px 3px;
width: 63%;
margin-bottom:10px;
}
#title{
height: 38px;
width: 55%;
}
</style>
<div class="cvr_div">
<div class="heading">
<h1>Categories</h1>
</div>
<div class="add_btn">
<a href=" <?php echo get_admin_url() ?>admin.php?page=categories&addcategory=1" class="button-primary hid">Add New Category</a>
</div>
</div>
<?php
//delete
if($_REQUEST['delete_id']){
$delete="DELETE FROM ".SE_SERMONS_CATEGORY." WHERE `id` =".$_REQUEST['delete_id'];
$del_qry=mysql_query($delete);
echo '<div class="delete_msg" style="background:red;"><span style="color:white; padding:0 0 0 7px;">Your Data has been successfully Deleted.</span></div>';?>
<script>
var $=jQuery.noConflict();
$(".delete_msg").slideUp(5000);
</script>
<?php } ?>
<?php if($_REQUEST['addcategory']){ ?>
<style>.add_btn{display:none;}</style>
<div class="cover_div">
<form method="post" action="<?php get_admin_url ?>admin.php?page=categories">
<table class="wp-list-table widefat fixed pages">
<thead>
<th><b>Category Type</b></th>
</thead>
<tbody>
<tr><td><div class="tr_cvr"><label for="cat_name" style="font-size:18px;">Category Name</label>
<input type="text" name="cat_txt" class="cat_txt" required="required" id="title"/></td></tr>
<tr><td><input type="submit" name="cat_save" value="Add Category" class="button-primary" /></div></td>
</tr>
</tbody>
</table>
</form>
</div>
<?php }
else if($_REQUEST['edit_id']){ ?>
<style>.add_btn{display:none;}</style>
<form method="post" action="<?php get_admin_url ?>admin.php?page=categories">
<table class="wp-list-table widefat fixed pages">
<thead>
<th><b>Category Type</b></th>
</thead>
<tbody>
<tr><?php
$select_qry="SELECT * FROM ".SE_SERMONS_CATEGORY." WHERE id=".$_REQUEST['edit_id'];
$qru=mysql_query($select_qry);
$row=mysql_fetch_assoc($qru);?>
<td><div class="tr_cvr"><label for="cat_name" style="font-size:18px;">Category Name</label>
<input type="text" name="cat_txt" class="cat_txt" required="required" value="<?php echo $row['category_name'] ?>" id="title"/>
<input type="hidden" value="<?php echo $row['id'] ?>" name="edit_hid"/>
</td></tr>
<tr><td><input type="submit" name="edit_cat" value="Update Category" class="button-primary" /></div></td>
</tr>
</tbody>
</table>
</form>
<?php }
else{?>
<table class="wp-list-table widefat fixed pages" style="width:65%;">
<thead>
<th width="10%"><b>S.No</b></th>
<th><b>Category Name</b></th>
<th width="12%"><b>Action</b></th>
</thead>
<tbody>
<tr><?php
//insert
if($_POST['cat_save']){?>
<script></script>
<?php $insert_cat="INSERT INTO ".SE_SERMONS_CATEGORY."(`category_name`,`category_slug`) VALUES('".$_POST['cat_txt']."','".sanitize_title($_POST['cat_txt'])."')";
mysql_query($insert_cat);
echo '<div class="success_msg"><span style="color:white; padding:0 0 0 7px; text-align:center;">Your Category has been successfully Inserted</span></div>';?>
<script>
var $=jQuery.noConflict();
$(".success_msg").slideUp(5000);
</script>
<?php } ?>
<?php if($_POST['edit_cat']){
$update="UPDATE ".SE_SERMONS_CATEGORY." SET `category_name`='".$_POST['cat_txt']."',`category_slug`='".sanitize_title($_POST['cat_txt'])."' WHERE id=".$_POST['edit_hid'];
mysql_query($update);
echo '<div class="success_msg"><span style="color:white; padding:0 0 0 7px;">Your Category has been successfully Updated</span></div>';?>
<script>
var $=jQuery.noConflict();
$(".success_msg").slideUp(5000);
</script>
<?php } ?>
<?php //select
$select_qry="SELECT * FROM ".SE_SERMONS_CATEGORY."";
$qru=mysql_query($select_qry);
$count=mysql_num_rows($qru);
if($count==0){
echo '<td colspan="3" align="center" style="color:red;"> No Categories Found</td>';
}
else{
$i=1;
while($row=mysql_fetch_assoc($qru)){?>
<tr><td><?php echo $i; ?></td>
<td><?php echo $row['category_name'];?></td>
<td>
<a href="?page=categories&edit_id=<?php echo $row['id'];?>"><img src="<?php echo ICT_SE_URL; ?>/images/edit.png"/></a>
<a onClick="return confirm('Are you Sure to Delete?')"href="?page=categories&delete_id=<?php echo $row['id'];?>"><img src="<?php echo ICT_SE_URL; ?>/images/delete.png"/></a>
</td></tr>
<?php $i++;} }?>
</tbody>
</table>
<?php } ?>