[PHP] Re: limit items per page

2001-07-23 Thread James Holloway

Hi Steph,

as the name suggests, use LIMIT ;)

Ie,

SELECT * FROM TABLE LIMIT 0,25

The 0 (or other number) is optional, and tells the table which row to start
limiting from, the secon number is the number of rows to limit to.. So:

SELECT * FROM TABLE LIMIT 25,25

Would bring out 25 rows, starting from row 25 (rows 25 to 50).  See the
documentation at the mysql site for more info.

Cheers,
James.


Steph [EMAIL PROTECTED] wrote in message
001701c11354$db6b2fa0$ab8d7a3f@vaio">news:001701c11354$db6b2fa0$ab8d7a3f@vaio...
Ive got an image gallery, and rather than having one really long page of
thumbnails, I'd like to have around 25 thumbnails (5 rows of 5 thumbs) per
page. Can you guys point me in the right direction??

Steph




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: limit items per page

2001-07-23 Thread Henrik Hansen

[EMAIL PROTECTED] (James Holloway) wrote:

  Hi Steph,
  
  as the name suggests, use LIMIT ;)

AFAIK it's mysql specific (at least it does not work with mssql)

-- 
Henrik Hansen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: limit items per page

2001-07-23 Thread James Holloway

Perhaps I shouldn't have made the assumption that steph was using mysql :)

Henrik Hansen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 [EMAIL PROTECTED] (James Holloway) wrote:

   Hi Steph,
  
   as the name suggests, use LIMIT ;)

 AFAIK it's mysql specific (at least it does not work with mssql)

 --
 Henrik Hansen



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: limit items per page

2001-07-23 Thread Martin Cameron

Here's a Quick  Dirty script that I ran up to get a display of 10 items per 
page with each click on a hyper-linked page returning a new page .. if you 
know what I mean. I've even included the headers so that any newbies can see 
the complete script and not just bits. The theory is that the first sql 
statement goes and gets the total number of rows for the display. This is 
then held in a global variable. The second query goes and gets the rows 
limited by an incrementing number. Simple, huh!

?
  include(radius.inc);
radius_db_connect();
define (INITIAL_PAGE,0);
 
$sql=select distinct username from user;
$res=mysql_query($sql) or die (OK);;
$num_rows=mysql_num_rows($res);
$j=1;
$i=0;
 
function initial_page(){
   global $PHP_SELF, $num_rows, $i,$j, $n;
   $sql=select distinct username from user limit $n, 10;
   $res=mysql_query($sql);
   while($row=mysql_fetch_array($res)){
  print $row[username].br;
   }
   $k=0;
   while($i = $num_rows){
  print a href = '$PHP_SELF?action=0n=$i' [$k]nbsp/a\n;
  $k++;
  $i+=10;
   }
}
 
switch($action){
 case INITIAL_PAGE:
   initial_page();
   break;
 default:
   die (Could not find function number $action);
}
?


On Mon, 23 Jul 2001 21:25, you wrote:
 Perhaps I shouldn't have made the assumption that steph was using mysql :)

 Henrik Hansen [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  [EMAIL PROTECTED] (James Holloway) wrote:
Hi Steph,
   
as the name suggests, use LIMIT ;)
 
  AFAIK it's mysql specific (at least it does not work with mssql)
 
  --
  Henrik Hansen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]