-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_topic.php
66 lines (64 loc) · 1.9 KB
/
manage_topic.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
<?php include 'conn_db.php' ?>
<?php
if(isset($_GET['id'])){
$qry = $conn->query("SELECT * FROM topics where id=".$_GET['id'])->fetch_array();
foreach($qry as $k =>$v){
$$k = $v;
}
}
?>
<div class="container-fluid">
<form action="" id="manage-topic">
<input type="hidden" name="id" value="<?php echo isset($_GET['id']) ? $_GET['id']:'' ?>" class="form-control">
<div class="row form-group">
<div class="col-md-8">
<label class="control-label">Title</label>
<input type="text" name="title" class="form-control" value="<?php echo isset($title) ? $title:'' ?>">
</div>
</div>
<div class="row form-group">
<div class="col-md-8">
<label class="control-label">Tags/Category</label>
<select name="category_ids[]" id="category_ids" multiple="multiple" class="custom-select select2">
<option value=""></option>
<?php
$tag = $conn->query("SELECT * FROM categories order by name asc");
while($row= $tag->fetch_assoc()):
?>
<option value="<?php echo $row['id'] ?>" <?php echo isset($category_ids) && in_array($row['id'], explode(",",$category_ids)) ? "selected" : '' ?>><?php echo $row['name'] ?></option>
<?php endwhile; ?>
</select>
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label class="control-label">Content</label>
<textarea name="content" class="text-jqte"><?php echo isset($content) ? $content : '' ?></textarea>
</div>
</div>
</form>
</div>
<script>
$('.select2').select2({
placeholder:"Please select here",
width:"100%"
})
$('.text-jqte').jqte();
$('#manage-topic').submit(function(e){
e.preventDefault()
start_load()
$.ajax({
url:'ajax.php?action=save_topic',
method:'POST',
data:$(this).serialize(),
success:function(resp){
if(resp == 1){
alert_toast("Data successfully saved.",'success')
setTimeout(function(){
location.reload()
},1000)
}
}
})
})
</script>