-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
55 lines (44 loc) · 2.12 KB
/
admin.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
<?php require 'header.php';?>
<?php
if(isset($_SESSION['admin'])){
if($_SESSION['admin'] == 'y'){
echo'<a href="createjob.php"> Add a job</a> <a href="createcategory.php">Add a category</a><br/><br/><br/> ';
$results = $pdo->query('SELECT * FROM categories');
foreach ($results as $rows){
echo '<input type="checkbox" name ="cat" value="'.$rows['category_id'].'" >'.$rows['name'].'<a href="editcategory.php?cat='.$rows['category_id'].'"> Edit category</a>'.'<a href="deletecategory.php?cat='.$rows['category_id'].'"> Delete category</a>'.'<br/>';
}
?>
<input type="submit" name="catSearch" value="Go">
</form>
<div id="jobs" style="display:block;">
<?php
$categories = $pdo->query('SELECT * FROM categories');
$cat_num = $categories->rowCount();
$cat_array = [];
for ($x = 1; $x <= $cat_num; $x++) {
$cat_array[$x] = $x;
}
if(isset($_POST['catSearch'])){
echo '<ul>';
$stmt = $pdo->prepare('SELECT * FROM jobs WHERE category_id = :cat');
$criteria = [
'cat' => $_POST['cat']
];
$stmt->execute($criteria);
while ($rows = $stmt->fetch()) {
echo'<li>Job name: '.$rows['job_name'].', Job Ref: '.$rows['job_id'].', Job salary: '.$rows['job_salary'].', Job Description: '.$rows['job_desc'].', Job Location: '.$rows['job_location'].', Job Cateory: '.$rows['category_id'].'; <a href="editjob.php?id='.$rows['job_id'].'">Edit</a>'.'; <a href="deletejob.php?id='.$rows['job_id'].'">Delete</a>'.'; <a href="listapplicants.php?id='.$rows['job_id'].'">List Applicants</a>'.'</li>';
}
echo'</ul>';
}
else{
$jobs = $pdo->query('SELECT * FROM jobs');
echo'<ul>';
foreach($jobs as $rows){
echo'<li>Job name: '.$rows['job_name'].', Job Ref: '.$rows['job_id'].', Job salary: '.$rows['job_salary'].', Job Description: '.$rows['job_desc'].', Job Location: '.$rows['job_location'].', Job Cateory: '.$rows['category_id'].'; <a href="editjob.php?id='.$rows['job_id'].'">Edit</a>'.'; <a href="deletejob.php?id='.$rows['job_id'].'">Delete</a>'.'; <a href="listapplicants.php?id='.$rows['job_id'].'">List Applicants</a>'.'</li>';
}
echo'</ul>';
}
}
}
?>
<?php require 'footer.php';?>