-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewcat.php
More file actions
47 lines (41 loc) · 1.33 KB
/
viewcat.php
File metadata and controls
47 lines (41 loc) · 1.33 KB
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
<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE");
require 'config.php';
if(isset($_GET['id'])==TRUE){
if(is_numeric($_GET['id'])==FALSE){
$error=1;
}
if($error==1){
header("Location:".$config_basedir."/viewcat.php");
}else{
$validcat=$_GET['id'];
}
}
else{
$validcat=1;
}
require 'header.php';
$db = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase);
$sql = "select * from categories";
$result = $db->query($sql);
while($row = mysqli_fetch_assoc($result)){
if($row['id']==$validcat){
echo "<strong>".$row['cat']."</strong><br/>";
$entriessql = "select * from entries where cat_id=".$validcat." order by dateposted desc;";
$entriesres = $db->query($entriessql);
$numrows_entries = $entriesres->num_rows;
echo "<ul>";
if($numrows_entries==0){
echo "<li>No entries!</li>";
}else{
while($entriesrow = mysqli_fetch_assoc($entriesres)){
echo "<li>".date("D jS F Y g.iA",strtotime($entriesrow['dateposted']))."-<a href='viewentry.php?id=".$entriesrow['id']."'>".$entriesrow['subject']."</a></li>";
}
}
echo "</ul>";
}
else{
echo "<a href='viewcat.php?id=".$row['id']."'>".$row['cat']."</a><br/>";
}
}
require 'footer.php';