1
0
mirror of https://github.com/glmdev/eecs448-lab10 synced 2024-10-27 19:14:00 +00:00
eecs448-lab10/DeletePost.html

42 lines
1.0 KiB
HTML
Raw Permalink Normal View History

2020-12-06 19:58:02 +00:00
<?php
require './configuration.php';
$db = new common\database\Connection;
$db->connect();
$page = new common\Page;
$page->title('EECS 448 Lab 10 - Exercise 7')
->header('Delete Posts');
$query = "SELECT post.post_id, user.username, post.content
FROM posts post
LEFT JOIN users user
ON user.user_id = post.post_id";
$results = $db->fetch($query);
$post_display = array_merge([
['Post ID', 'Username', 'Content', 'Delete?'],
], array_map(function($post) {
$id = 'post-' . $post['post_id'];
return [
$post['post_id'],
$post['username'],
$post['content'],
'<input type="checkbox" id="' . $id . '" name="' . $id . '" value="yes">
<label for="' . $id . '">Delete</label>'
];
}, $results));
$page->writes('<p>Select the posts you want to delete.')
->form(system_url('DeletePost.php'), function() use($page, $post_display) {
$page->table($post_display)
->writes('<br>')
->submit();
});
$page->write();