Alternatively, CPKILLER. This needs to be rewritten in places and optimized. Based heavily (as in 95% of it) on Thornlight */ require_once "config.php"; require_once "common.php"; require_once "auth-common.php"; if (!$_SESSION['admin'] && !$_SESSION['moderator']) { THdie("Sorry, you do not have the proper permissions set to be here, or you are not logged in."); } else { $db = new ThornDBI(); // SELECT COUNT(*) FROM 'img' $count = $db->myresult("SELECT COUNT(*) FROM " . THimages_table); $offset = 0; $orpha = 20; //how many on each page if (isset($_GET['offset'])) { $offset = intval($_GET['offset']); if ($offset < 0) { $offset = 0; } } $beginning = $count - $orpha - $offset; if ($beginning < 0) { $beginning = 0; } //Beginning should never be greater than $count, for the reason that $offset is always >= 0 $imagequery = "SELECT * FROM " . THimages_table . " ORDER BY id ASC LIMIT {$beginning} , {$orpha}";