FORUM HOME | WHUK BLOG   
WEB HOSTING UK AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM
PHP LINUX SHARED HOSTING WINDOWS ASP.NET HOSTING PACKAGES
ECOMMERCE HOSTING ASP MSSQL MS ACCESS ODBC FRONTPAGE HOSTING
CPANEL WHM FANTASTICO RESELLER DEDICATED SERVER WEB HOSTING
CHEAP PLESK CPANEL HTML MYSQL BEST UK VPS HOSTING COMPANY
CHEAP RELIABLE UK HOSTING PROVIDER SINCE 2001
MANAGED WEB HOSTING SERVICE
AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM

Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum » Technical Support » PHP Hosting

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 16-02-10, 01:28 AM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default Limiting records per page?

Hi people,

I'm trying to get this page LogicalCups || #ficomedia @ Qnet - COD4 Cups, Night Cups - News limited by X amount of records per page. Anyone know how I can do this please?

Much appreciated.

Thank you.
Reply With Quote

  #2 (permalink)  
Old 16-02-10, 01:07 PM
Member
 
Join Date: Feb 2010
Posts: 36
Default

Hi there, when you do your query to the database to pull the info into your page.
Add LIMIT 1 to the query.

Example:

$sql = "SELECT * FROM table LIMIT 1;

Or change the 1 to however many results you would like to pull from the database.
:O)
Reply With Quote

  #3 (permalink)  
Old 16-02-10, 08:10 PM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default

Yes but I want all records to be displayed into multi pages? Not just a limit itself.
Reply With Quote

  #4 (permalink)  
Old 16-02-10, 08:18 PM
Member
 
Join Date: Feb 2010
Posts: 36
Default

Are you talking about pagination?

With links to the next page i.e:

<first page | 2 | 3 | 4 | 5 | last page>
Reply With Quote

  #5 (permalink)  
Old 16-02-10, 10:19 PM
Dan's Avatar
Dan Dan is offline
Got root?
 
Join Date: Aug 2007
Location: England, UK.
Posts: 1,340
Send a message via ICQ to Dan Send a message via AIM to Dan Send a message via MSN to Dan Send a message via Yahoo to Dan Send a message via Skype™ to Dan
Default

Here is an article explaining how to do it.

Pagination - PHP Pagination - PHP MySQL Pagination
__________________
Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

Sales: 0808-262-0855
Support: 0800-612-8725
International: +44 191 303 8191
Reply With Quote

  #6 (permalink)  
Old 17-02-10, 11:43 AM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default

Nice! but where it tells me to specify $max, this just breaks the page?

("SELECT * FROM ".PREFIX."cup_all_clans $max")
Reply With Quote

  #7 (permalink)  
Old 17-02-10, 12:53 PM
Member
 
Join Date: Feb 2010
Posts: 36
Default

Hey karimali831
try this one out, its pretty basic, but if you have never worked with pagination before it will be a bit easier to understand.

PHP Freaks - Tutorial: PHP Basic Pagination
Reply With Quote

  #8 (permalink)  
Old 17-02-10, 05:57 PM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default

Thanks
Working on it now.
Reply With Quote

  #9 (permalink)  
Old 18-02-10, 12:24 PM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default

I tried many with no luck I'm afraid.
I thought I could just use include("pagination.php"); on main page and change the query but it will just break the page.

If you take a look at my clans.php maybe you can see the problem. Must I include the pagination script within clans.php itself? Again, breaks the page. Never used this before.
Attached Files
File Type: zip clans.zip (8.0 KB, 3 views)
Reply With Quote

  #10 (permalink)  
Old 26-02-10, 07:50 PM
Senior Member
 
Join Date: Jan 2007
Location: Dorset
Posts: 1,119
Default

Not had a look at your script but try using mine.

Code:
$pagenum=$_GET['pagenum'];
$connect=connect to databse script..
//get count    
$query2 = "SELECT count(*)FROM TABLE";
$result2=mysql_query ($query2, $connection) or die('Queryproblem: ' . mysql_error() . '<br />Executed query: ' . $query2); 
$numrows=mysql_result ($result2,0,"count(*)"); 
$all=$numrows;
     
//the pagination

$rows_per_page = 8;
$last = ceil($numrows/$rows_per_page);
$pagenum = (int)$pagenum;
if ($pagenum < 1) {
$pagenum = 1;
} elseif ($pagenum > $last) {
$pagenum = $last;
}
$limit = 'LIMIT ' .($pagenum - 1) * $rows_per_page .',' .$rows_per_page;

if ($pagenum == 1) {
// echo "FIRST PREV";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'>FIRST</a> ";
$prevpage = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$prevpage'>PREV</a> ";
}
echo " ( Page $pagenum of $last ) ";
if ($pagenum == $last) {
//echo " NEXT LAST ";
} else {
$nextpage = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$nextpage'>NEXT</a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>LAST</a> ";
}
?>
Reply With Quote

  #11 (permalink)  
Old 27-02-10, 05:11 PM
Senior Member
 
Join Date: Dec 2006
Posts: 684
Send a message via MSN to karimali831
Default

got it working! thanks
Reply With Quote

  #12 (permalink)  
Old 18-04-11, 09:56 AM
new member
 
Join Date: Feb 2011
Posts: 7
Default

change the 1 to however many results you would like to pull from the database.
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT. The time now is 08:12 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Copyright 2001-2010 Web Hosting UK. All rights reserved.
Web Hosting UK Forum





Site Map

Shared Cloud
Shared Cloud From £1

Affiliate Program
Earn up to £300 Per Sale

Dedicated Servers
Dedicated Server Hosting

Cloud Hosting
Cloud Server Hosting

Load Balanced Server
Load Balancing Server

VPS Hosting
Linux VPS Hosting

Windows VPS
Windows 2003 VPS

Zimbra Hosting
Zimbra Email Hosting

cPanel Hosting
Shared Linux Hosting

Windows Hosting
Shared Windows Hosting

Coldfusion Hosting
Windows Coldfusion Hosting

cPanel Reseller Hosting
Reseller Hosting

Windows Reseller
Windows Reseller Hosting

Email Web Hosting
Email Hosting

Semi-Dedicated Server
Semi-Dedicated Hosting

Remote Backup Plans
Offsite Backup Service


cpanel hosting
Knowledgebase Articles

Pre-Sales Question
Web Hosting FAQ's

Dedicated Hosting
Dedicated Server FAQ's

Virtual Private Servers
VPS Hosting

PHP MySQL Hosting
cPanel Hosting

Windows Hosting
ASP MSSQL Hosting

Domain Name
Domain registration FAQ's

CMS Hosting
CMS Hosting FAQ's

Payment Gateways
Payment FAQ's


Support Tutorials

cPanel Tutorials
cPanel Flash Tutorials

Wordpress Tutorials
Wordpress Flash Tutorials

Plesk Tutorials
Plesk Flash Tutorials

PhpMyadmin Tutorials
PhpMyadmin Flash Tutorials

Drupal Tutorials
Drupal Flash Tutorials

Mambo Tutorials
Mambo Flash Tutorials

Joomla Tutorials
Joomla Flash Tutorials

More Hosting Tutorials