-
Notifications
You must be signed in to change notification settings - Fork 3
/
books.php
27 lines (24 loc) · 869 Bytes
/
books.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
<?php
require_once 'util.php';
require_once 'db_helper.php';
$db = getDBInstance();
if(!isset($_REQUEST['id'])){
$sql = 'select * from books order by create_time desc';
$title = _('New Upload Books');
$category = null;
}else{
$id = decode_and_int($_REQUEST['id']);
$sql = "SELECT b.* FROM books b, book_category bc where b.id=bc.book_id and bc.category_id=$id";
$category = getRowById($db, 'categories', $id);
$title = $category->name;
}
$current = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
$books = paginate($db, $sql, $current,$perpage=30);
$smarty = getSmartyInstance();
// var_dump($books);
$smarty->assign('books',$books);
$smarty->assign('title',$title);
$smarty->assign('category',$category);
$smarty->assign('page_url',$category ? 'books.php?id='.encode($category->id) : 'books.php');
$smarty->display('books.html');
?>