Ejemplo n.º 1
0
<?php

echo "hello";
session_start();
require 'Smarty.class.php';
require 'SmartyPaginate.class.php';
$smarty =& new Smarty();
// 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);
// display results
$smarty->display('index.tpl');
function get_db_results()
{
    // normally you would have an SQL query here,
    // for this example we fabricate a 100 item array
    // (emulating a table with 100 records)
    // and slice out our pagination range
    // (emulating a LIMIT X,Y MySQL clause)
    $_data = range(1, 100);
    SmartyPaginate::setTotal(count($_data));
    return array_slice($_data, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
}
Ejemplo n.º 2
0
 /**
  * @return DB
  */
 private function getDataRecords()
 {
     DateDataTypeHandler::$MASK_CUSTOM = 'Y-m-d';
     ini_set('max_execution_time', 0);
     $records = get_db_results(TRUE, $this->requestDataSet->name, $this->requestDataSet->columns, $this->requestDataSet->parameters, $this->requestDataSet->sortColumn, $this->requestDataSet->startWith, $this->requestDataSet->limit, NULL);
     return $records;
 }
Ejemplo n.º 3
0
    die("Please use php-cli\n");
}
require "functions.php";
require "candidates.php";
require "settings.php";
restore_error_handler();
error_reporting(E_ALL);
ini_set('display_errors', 'On');
if (empty($settings['show_res_secret'])) {
    die("Not configured\n");
}
if ($argv[2] != $settings['show_res_secret']) {
    die("Usage: php show_res.php <mode> <secret>\n");
}
if ($argv[1] == "db") {
    $res = get_db_results();
}
if ($argv[1] == "file") {
    $res = get_file_results();
}
$res = transcode_results($res);
show_results($res);
exit;
function get_db_results()
{
    $db = db_connect();
    $res = $db->query("SELECT choice FROM ballot_box");
    $out = array();
    while ($obj = $res->fetch_object()) {
        $out[] = $obj->choice;
    }