-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse.php
119 lines (111 loc) · 6.01 KB
/
course.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
<?php include "includes/head.php"; ?>
<?php
$error = 0;
$row = [];
$table = "courses";
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = trim($_GET['id']);
$getData = $conn->prepare("SELECT * FROM `${table}` WHERE id = ?");
$getData->execute([$id]);
if($getData->rowCount() > 0){
$row = $getData->fetch(PDO::FETCH_OBJ);
}
}
else{
$error = 1;
}
if($error == 1 && empty($row)){
echo '<h3>Access Forbidden</h3>';
}
else{
if(isset($_POST['submit'])){
$islive = $_POST['islive'];
$editData = $conn->prepare("UPDATE courses SET islive=? WHERE id=?");
$editData->execute([
$islive, $id
]);
if($editData->rowCount() > 0){
echo "<div class='alert alert-success'>Updated.</div>";
}
if($editData->rowCount() == 0){
echo "<div class='alert alert-danger'>Failed.</div>";
}
}
?>
<?php $getUser = $conn->query("SELECT * FROM users WHERE id = '$row->ecoach_id'"); $user = $getUser->fetch(PDO::FETCH_OBJ); ?>
<!-- Start info box -->
<div class="row mt-5" style="display:flex;justify-content:center;">
<div class="col-md-6">
<div class="widget">
<div class="widget-header">
<h4><b>Manage Course</b></h4>
</div>
<div class="widget-content" style="padding:10px;">
<form method="post">
<div class="form-group">
<label>Creator</label>
<input type="text" value="<?php echo $row->creator; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Original Price(₦)</label>
<input type="text" value="<?php echo $row->price; ?>" class="form-control"/>
</div>
<div class="form-group">
<label>Sale Price(₦)</label>
<input type="text" value="<?php echo $row->discount; ?>" class="form-control"/>
</div>
<div class="form-group">
<label>Title</label>
<input type="text" value="<?php echo $row->title; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Category</label>
<input type="text" value="<?php $getCategory = $conn->query("SELECT * FROM categories WHERE id = '$row->category_id'");
$category = $getCategory->fetch(PDO::FETCH_OBJ);
echo $category->title; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Tags</label>
<input type="text" value="<?php echo $row->tags; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Belongs To</label>
<input type="text" value="<?php echo $row->belongs_to; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Total Time</label>
<input type="text" value="<?php echo $row->total_time; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Affiliate Percentage(%)</label>
<input type="text" value="<?php echo $row->affiliate_percentage; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Intro Video</label>
<input type="text" value="<?php echo $row->intro_video; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Description</label>
<p><?php echo $row->description; ?></p>
</div>
<div class="form-group">
<label>Status</label>
<p><?php echo $row->status; ?></p>
</div>
<div class="form-group">
<label>Is Live</label>
<select name="islive" class="form-control">
<option <?php if($row->islive == 1){ echo "selected"; } ?> value="1">yes</option>
<option <?php if($row->islive == 0){ echo "selected"; } ?> value="0">no</option>
</select>
</div>
<hr>
<button type="submit" name="submit" class="btn btn-block btn-md btn-success">Update</button>
</form>
</div>
</div>
</div>
</div>
<!-- End of info box -->
<?php } ?>
<?php include "includes/foot.php"; ?>