Ad block is installed and active. Please support us by disabling it.
HomeThursday, September 21, 2017, 03:21:57
3

Smarty Paginate Example - Smarty Pagination with PHP

Monday, February 9, 15, 02:08:43, 3 Yaers Ago Via wain, Hits: 3677
Smarty Paginate Example, Smarty Pagination with PHP. SmartyPaginate: a class/plugin for data set pagination within the Smarty template environment
Resource Smarty Paginate:

search.php

Code:
function get_db_results()
{
$id = $_GET['id'];
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM links WHERE linkname LIKE '%%$id%%' LIMIT %d,%d", SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
$_result = mysql_query($_query);
while ($_row = mysql_fetch_array($_result, MYSQL_ASSOC)) {
$_data[] = $_row;
}
$_query = "SELECT FOUND_ROWS() as total";
$_result = mysql_query($_query);
$_row = mysql_fetch_array($_result, MYSQL_ASSOC);
SmartyPaginate::setTotal($_row['total']);
mysql_free_result($_result);
return @$_data;
}
require ('libs/SmartyPaginate.class.php');
SmartyPaginate::connect();
SmartyPaginate::setLimit(10);
SmartyPaginate::setUrl('search.php');
$smarty->assign('results', get_db_results());
SmartyPaginate::assign($smarty);
$smarty->display('search.php');


search.php(template)

Code:
{section name="results" loop=$results}
{$results[results].linkname}<br />
{/section}

Links {$paginate.first}-{$paginate.last} of {$paginate.total}.
{paginate_prev} {paginate_next}


jeremy Monday, November 19, 2012, 15:50:07

Thank you for useful code example

Sign In

Sponsor

Related

Process Form Data with Jquery

jQuery, Process form data

Preventing multiple form submissions

Preventing multiple form submissions

Bookmark Current Page - PHP Tutorial

Bookmark current page with PHP example.

PHP Trim

trim() Strip whitespace (or other characters) from the beginning and end of a string.

Convert pdf to image - mpdf

Convert pdf file to jpg with php and mpdf

PHP Write to File

PHP Write to File :: PHP Tutorial, requirement(s): PHP server

Smarty - Create dynamic Web Pages with PHP & MySQL

Creating Dynamic Web Pages Using Smarty and MySQL - Requirement(s): PHP Server, MySQL

Timed Redirect JavaScript

Timed redirect javaScript/PHP example

PHP Form Basic

PHP Form - PHP form basic, Requirement(s): PHP Server
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.