HomeSaturday, August 18, 2018, 20:18:46
3

Smarty Paginate Example - Smarty Pagination with PHP

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

PHP $_GET Function

Get function in PHP

PHP explode

Explode — Split a string by string.

ShoutBox 1.1. PHP Script

ShoutBox allows your users to post short messages on your site. The script is lightweight and very easy to install and use.

Filter Words in PHP - PHP Tutorial

Filter bad words in PHP, requirement(s): PHP server

Syntax highlighting in Smarty

Syntax highlighting for Smarty - Google Code Prettify

How to check checkbox checked

Checking if checkbox is checked with jQuery

Adodb Recordcount Example

RecordCount returns the number of rows in the record set.

MySQL to RSS

Publishing MySQL data in RSS

Meta Tags Generator 1.1. PHP Script

This script will allow your visitors to create meta tags online.

Tell A Friend with Captcha

This form allows your visitors to suggest your site to a friend. It features an HTML email format and an admin notification email.
About Author

wain

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