-
Notifications
You must be signed in to change notification settings - Fork 15
/
update_article.php
150 lines (99 loc) · 5.02 KB
/
update_article.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
<!-- Include Head -->
<?php include "assest/head.php"; ?>
<?php
$article_id = $_GET["id"];
// Get article Data to display
$stmt = $conn->prepare("SELECT * FROM article WHERE article_id = ?");
$stmt->execute([$article_id]);
$article = $stmt->fetch();
// Get categories Data to display
$stmt = $conn->prepare("SELECT category_id, category_name FROM category");
$stmt->execute();
$categories = $stmt->fetchAll();
// Get authors Data to display
$stmt = $conn->prepare("SELECT author_id, author_fullname FROM author");
$stmt->execute();
$authors = $stmt->fetchAll();
?>
<!-- JS TextEditor -->
<script src="//cdn.ckeditor.com/4.13.1/standard/ckeditor.js"></script>
<title>Update Article</title>
</head>
<body>
<!-- Header -->
<?php include "assest/header.php" ?>
<!-- Main -->
<main role="main" class="main">
<div class="jumbotron text-center">
<h1 class="display-3 font-weight-normal text-muted">Update Article</h1>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 mb-4">
<!-- Form -->
<form action="assest/update.php?type=article&id=<?= $article_id ?>&img=<?= $article["article_image"] ?>" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="arTitle">Title</label>
<input type="text" class="form-control" name="arTitle" id="arTitle" value="<?= $article["article_title"] ?>">
</div>
<div class="form-group">
<label for="arContent">Content</label>
<textarea class="form-control" name="arContent" id="arContent" rows="3">
<?= $article["article_content"] ?>
</textarea>
</div>
<div class="form-group">
<label for="UploadImage">Image</label>
<div class="custom-file">
<input type="file" class="custom-file-input" name="arImage" id="arImage">
<label class="custom-file-label" for="UploadImage"> <?= $article['article_image'] ?></label>
</div>
</div>
<div class="my-2" style="width: 200px;">
<img class="w-100 h-auto" src="img/article/<?= $article["article_image"] ?>" alt="">
</div>
<div class="form-group">
<label for="arCategory">Category</label>
<select class="custom-select" name="arCategory" id="arCategory">
<option disabled>-- Select Category --</option>
<?php foreach ($categories as $category) : ?>
<?php if ($article['id_categorie'] == $category['category_id']) : ?>
<option value="<?= $category['category_id'] ?>" selected><?= $category['category_name'] ?></option>
<?php else : ?>
<option value="<?= $category['category_id'] ?>"><?= $category['category_name'] ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="arauthor">Author</label>
<select class="custom-select" name="arAuthor" id="arAuthor">
<option disabled>-- Select Author --</option>
<?php foreach ($authors as $author) : ?>
<?php if ($article['id_author'] == $author['author_id']) : ?>
<option value="<?= $author['author_id'] ?>" selected><?= $author['author_fullname'] ?></option>
<?php else : ?>
<option value="<?= $author['author_id'] ?>"><?= $author['author_fullname'] ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="text-center">
<button type="submit" name="update" class="btn btn-success btn-lg w-25">Update</button>
</div>
</form>
</div>
<div class="col-lg-4 mb-4">
<!-- <h1> Random Articles </h1> -->
</div>
</div>
</div>
</main>
<!-- Footer -->
<!-- <?php include "assest/footer.php" ?> -->
<!-- Text Editor Script -->
<script>
CKEDITOR.replace('arContent');
</script>
</body>
</html>