[PHP-DB] Re: NEXT - PREVIOUS coding

2001-08-14 Thread Boaz Amit

Hi,
what about other possibilities to do this ?

Tom

Other possibilities? Why not just utilize the second argument of the LIMIT function 
with a fairly simple SQL query?

Here's a portion of a script I wrote, modified to be an example on this matter:

?php

$articles_display_limit = 5; // set the number of articles to be displayed on each 
page

/*
$article_number sets the position in the database from which the current query results 
will begin from. $article_number is passed to the script as a GET method variable (i.e 
article.php?record_number=5)
*/

$articles = mysql_query(SELECT * FROM articles
 LIMIT $article_number,$articles_display_limit);

$next = $article_number + $articles_display_limit; // next page's starting point
$prev = $article_number - $articles_display_limit ; // previous page's starting 
point
$total_number_of_articles = mysql_num_rows(mysql_query(SELECT NULL FROM 
articles));

/* display this page's articles*/

 /* determine if a 'Previous' button is required */
if ($prev = 0) {
echo 'a href=article.php?article_number=' . $prev . 'Previous/a' . \n;
}

 /* determine if a 'Next' button is required */
if ($next  $total_number_of_articles) {
echo 'a href=article.php?article_number=' . $next . 'Next/a' . \n;
}

?

This should do the trick if I haven't modified too much.
There's a good but a bit messy article about it in PHPBuilder: 
http://phpbuilder.com/columns/rod2221.php3
The script is much more experienced and advanced than my own.

---
 regards,
  Boaz Amit


  Hello Pranot,
 
  On 16-Jul-01 06:09:33, you wrote:
 

  hi.. friends
  
  i have a database (mysql) in which their r many records. Through PHP i
want
   them to display on the page.
  
   Main requirement is that there should be a NEXT - PREVIOUS facility. So
if
   there r 20 records and suppose only 10 should show up on scren at a time,
   then a NEXT link should be visible which could show the remaining 10
   records.
  
   Their can be n no. of records.
  
  Maybe you would like to try this PHP class that does exactly what you are
  asking.
 
  http://phpclasses.UpperDesign.com/browse.html/package/130
 
 
  Regards,
  Manuel Lemos
 
  Web Programming Components using PHP Classes.
  Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
  --
  E-mail: [EMAIL PROTECTED]
  URL: http://www.mlemos.e-na.net/
  PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
  --
 





-- 
PHP Database 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-DB] Re: NEXT - PREVIOUS coding

2001-08-13 Thread Tom

Hi,
what about other possibilities to do this ?

Tom

U¿ytkownik Manuel Lemos [EMAIL PROTECTED] napisa³ w wiadomo¶ci
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Pranot,

 On 16-Jul-01 06:09:33, you wrote:


 hi.. friends

 i have a database (mysql) in which their r many records. Through PHP i
want
 them to display on the page.

 Main requirement is that there should be a NEXT - PREVIOUS facility. So
if
 there r 20 records and suppose only 10 should show up on scren at a time,
 then a NEXT link should be visible which could show the remaining 10
records.

 Their can be n no. of records.

 Maybe you would like to try this PHP class that does exactly what you are
 asking.

 http://phpclasses.UpperDesign.com/browse.html/package/130


 Regards,
 Manuel Lemos

 Web Programming Components using PHP Classes.
 Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
 --
 E-mail: [EMAIL PROTECTED]
 URL: http://www.mlemos.e-na.net/
 PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
 --




-- 
PHP Database 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-DB] Re: NEXT - PREVIOUS coding

2001-08-12 Thread Manuel Lemos

Hello Pranot,

On 16-Jul-01 06:09:33, you wrote:


hi.. friends

i have a database (mysql) in which their r many records. Through PHP i want
them to display on the page. 

Main requirement is that there should be a NEXT - PREVIOUS facility. So if
there r 20 records and suppose only 10 should show up on scren at a time,
then a NEXT link should be visible which could show the remaining 10 records.

Their can be n no. of records.

Maybe you would like to try this PHP class that does exactly what you are
asking.

http://phpclasses.UpperDesign.com/browse.html/package/130


Regards,
Manuel Lemos

Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
--
E-mail: [EMAIL PROTECTED]
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--


-- 
PHP Database 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-DB] Re: NEXT - PREVIOUS coding

2001-07-16 Thread Manuel Lemos

Hello,

Pranot Kokate wrote:
 
 hi.. friends
 
 i have a database (mysql) in which their r many records. Through PHP i want them to 
display on the page.
 
 Main requirement is that there should be a NEXT - PREVIOUS facility. So if there r 
20 records and suppose only 10 should show up on scren at a time, then a NEXT link 
should be visible which could show the remaining 10 records.
 
 Their can be n no. of records.

Usually you may use the LIMIT clause to specify the range of query
result rows that you want to show.

You may want to try this PHP class that already display query results in
HTML tables eventually spliting the results in pages that you may go
using links like you want.

http://phpclasses.UpperDesign.com/browse.html/package/130

Manuel Lemos

-- 
PHP Database 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]