Ad block is installed and active. Please support us by disabling it.
HomeSunday, November 19, 2017, 14:12:35
3

Smarty Paginate Example - Smarty Pagination with PHP

Monday, February 9, 15, 02:08:43, 3 Yaers Ago Via wain, Hits: 3988
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

Random MySQL Query

Random MySQL query, requirement(s): PHP Server, MySQL

PHP File Create

Create and write data to a file using the php frwite function.

PHP Form Basic

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

PHP getdate

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.

Imageline

Draws a line between the two given points.

Upload File with PHP

Basic file uploading with PHP

Upload Image With PHP

[Example3] Tutorial - How to upload image in php.

PHP $_POST Function

Collect values from a form sent with method post

Creating a CAPTCHA with PHP with imagecreate

This tutorial will show you how to create a form with Captcha, Requirement(s): PHP Server, GD Graphics Library
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.