This repository was archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: fitur update artikel dan komentar, update db
- Loading branch information
Showing
7 changed files
with
148 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
require_once '../templates/config/db_connection.php'; | ||
|
||
if (!isset($_SESSION['name'])) { | ||
header("Location: index.php"); | ||
} | ||
|
||
$id_artikel = (int)$_GET['id_artikel']; | ||
|
||
// check if id_artikel is exist | ||
$query = "SELECT * FROM t_artikel WHERE id_artikel=?"; | ||
$stmt = $connection->prepare($query); | ||
$stmt->bind_param("i", $id_artikel); | ||
$stmt->execute(); | ||
$result = $stmt->get_result(); | ||
|
||
if ($result->num_rows > 0) { | ||
$row = $result->fetch_assoc(); | ||
$new_status = !$row['status_komentar']; | ||
// update data | ||
$status = ($new_status) ? "DIBUKA" : "DITUTUP"; | ||
echo "<script>alert('KOLOM KOMENTAR BERHASIL " . $status . ")</script>"; | ||
$query = "UPDATE t_artikel SET status_komentar = ? WHERE id_artikel=?"; | ||
$stmt = $connection->prepare($query); | ||
$stmt->bind_param("ii", $new_status, $id_artikel); | ||
$stmt->execute(); | ||
header("Location: ../dashboard.php"); | ||
} else { | ||
echo "<script>alert('GAGAL MENGUBAH DATA')</script>"; | ||
} | ||
|
||
?> |
Oops, something went wrong.