コード例 #1
0
 /**
  * initialize the session data
  *
  * @param string $id the pagination id
  * @param string $formvar the variable containing submitted pagination information
  */
 public static function connect($id = 'default', $formvar = null)
 {
     if (!isset($_SESSION['SmartyPaginate'][$id])) {
         SmartyPaginate::reset($id);
     }
     // use $_GET by default unless otherwise specified
     $_formvar = isset($formvar) ? $formvar : $_GET;
     // set the current page
     $_total = SmartyPaginate::getTotal($id);
     if (isset($_formvar[SmartyPaginate::getUrlVar($id)]) && $_formvar[SmartyPaginate::getUrlVar($id)] > 0 && (!isset($_total) || $_formvar[SmartyPaginate::getUrlVar($id)] <= $_total)) {
         $_SESSION['SmartyPaginate'][$id]['current_item'] = $_formvar[$_SESSION['SmartyPaginate'][$id]['urlvar']];
     }
 }
コード例 #2
0
<?php

#reset session data
SmartyPaginate::reset();
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(10);
#set url for links
SmartyPaginate::setUrl('./index.php?path=./main/faqs/faqs.show_faqs.php');
SmartyPaginate::setPrevText('PREV');
SmartyPaginate::setNextText('NEXT');
function getSearchResults(&$dbcon)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT fq.*,C.value FROM sionapros_faqs AS fq INNER JOIN sionapros_categories";
    $searchSQL .= " AS C ON fq.category = C.id ORDER BY C.id,fq.id LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    echo $dbcon->error;
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_faqs WHERE 1";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;