-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcategories.php
More file actions
52 lines (41 loc) · 1.39 KB
/
categories.php
File metadata and controls
52 lines (41 loc) · 1.39 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
48
49
50
51
52
<?php
/*
+ ----------------------------------------------------------------------------+
| PHPDirector.
| $License: GPL General Public License
| $Website: phpdirector.co.uk
| $Author: Ben Swanson
| $Contributors - Dennis Berko and Monte Ohrt (Monte Ohrt)
+----------------------------------------------------------------------------+
*/
require("header.php");
$query_categories = mysql_query("SELECT * FROM pp_categories WHERE disable='0'");
if(mysql_num_rows($query_categories) == 0){ //if no categories display error.
$smarty->assign('error', "No Categoires Yet");
$smarty->display('error.tpl');
exit;
}
$result = array();
$i=0;
while ($row_cat = mysql_fetch_array($query_categories)) {
$cat_id = $row_cat['id'];
//gets info from first media file
//Checks if picture is blank if it is then it gets a image from the first video in that category
if ($row_cat['image'] == null){
$query_files = mysql_query("SELECT * FROM pp_files WHERE category = $cat_id AND approved = '1' ORDER BY views desc");
$row_file = mysql_fetch_array($query_files);
$picture = $row_file['picture'];
}else{
$picture = $row_cat['image'];
}
$tmp = array(
'id' => $row_cat['id'],
'name' => $row_cat['name'],
'picture' => $picture
);
$result[$i++] = $tmp;
}
$smarty->assign('cat', $result);
$smarty->display('category.tpl');
mysql_close($mysql_link);
?>