Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', '0'); # don't show any errors...
- error_reporting(E_ALL | E_STRICT); # ...but do log them
- session_start();
- include('../configs/pdo.inc.php');
- include('../libs/Smarty.class.php');
- require('../libs/SmartyPaginate.class.php');
- // create object
- $smarty = new Smarty;
- try {
- // required connect
- SmartyPaginate::connect();
- // set items per page
- SmartyPaginate::setLimit(25);
- // assign your db results to the template
- $smarty->assign('results', get_db_results());
- // assign {$paginate} var
- SmartyPaginate::assign($smarty);
- function get_db_results() {
- $_query = $oPDO->prepare("SELECT D_content * FROM T_Nieuws LIMIT %d,%d", SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
- $_result = $_query->execute();
- while ($_row = $_result->fetchAll(PDO::FETCH_ASSOC)) {
- // collect each record into $_data
- $_data[] = $_row;
- }
- // now we get the total number of records from the table
- $_query = $oPDO->prepare("SELECT FOUND_ROWS() as total");
- $_result = $_query->execute();
- $_row = $_result->fetchAll(PDO::FETCH_ASSOC);
- SmartyPaginate::setTotal($_row['total']);
- return $_data;
- }
- // Clubs ophalen
- // alleen de zichtbare records uit V_clubs halen
- $query = $oPDO->prepare("SELECT * FROM V_clubs WHERE Zichtbaar = 0 ORDER BY ID");
- $query->execute();
- // array anders sorteren om oproepen te vergemakkelijken
- $t = array();
- foreach ($query as $row) {
- $t[$row['ID']] = $row;
- }
- $smarty->assign('clubs', $t);
- // Clubteller
- $xclubs = $oPDO->prepare("SELECT ID from V_clubs");
- $xclubs->execute();
- $smarty->assign('xclubs', $xclubs->rowCount());
- // clubs verwijderen
- if (isset($_GET['actie'])) {
- if ($_GET['actie'] == 'delete') {
- $verwijderen = $oPDO->prepare("DELETE FROM T_clubs WHERE D_id = :getid");
- $verwijderen->bindValue(':getid', $_GET['clubid']); // door ID
- $verwijderen->execute();
- // resultaat weergeven
- if ($verwijderen) {
- $smarty->assign('resultaat', '<p class="success">Club verwijderd!</p>');
- }
- } elseif ($_GET['actie'] == 'accept') { // clubs aanvaarden
- $aanvaarden = $oPDO->prepare("UPDATE T_clubs SET D_zichtbaar = '1' WHERE D_id = :getid");
- $aanvaarden->bindValue(':getid', $_GET['clubid']); // ook door ID
- $aanvaarden->execute();
- // resultaat weergeven
- if ($aanvaarden) {
- $smarty->assign('resultaat', '<p class="success">Club toegevoegd!</p>');
- }
- }
- }
- } catch (PDOException $e) {
- echo '<pre>';
- echo 'Regelnummer: ' . $e->getLine() . '<br>';
- echo 'Bestand: ' . $e->getFile() . '<br>';
- echo 'Foutmelding: ' . $e->getMessage() . '<br>';
- echo '</pre>';
- }
- // display it
- $smarty->display('extends:a_layout.tpl|a_header.tpl|a_clubs.tpl');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement