Re: Limits and php...

From: Date: Fri, 10 Oct 2003 02:51:46 +0000
Subject: Re: Limits and php...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-165690@lists.php.net to get a copy of this message
In article <3F82CE2F.8040409@magidesign.com>, payne@magidesign.com says... > Hi, > > I have been trying to understand how to write a simple code that will > let me limit the number of files view to 10 records, but I need to > under how php can look at a number of records and then caculates how > many pages it needs to show all records. Is there some sample code that > shows how to calculate and how to show limits 0,5 5,10 so on and so on.... If you mean the number of records from a database, rather than files which you first mention, all you need to do is use COUNT(*) to determine the number of records found, then use some simple arithmetic and possibly the modulus operator to determine how many pages would be needed to display the records x at a time. For example, you have 57 records and you want to display 10 at a time. You will need at least 57/10 pages, plus one if 57 modulus 10 != 0. And the modulus operator in php is % Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet?

« previous php.general (#165690) next »