Re: [PHP] Page Numbers

2002-04-30 Thread Jason Wong

On Tuesday 30 April 2002 18:41, Craig wrote:
 Any one know how to display, go to page number on a record list page

 eg

 Prev 1|2|3|4|5|6... Next

Yes.

http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-answers.html

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Practical politics consists in ignoring facts.
-- Henry Adams
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Page Numbers

2002-04-30 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Craig declared
 Any one know how to display, go to page number on a record list page
 
 eg
 
 Prev 1|2|3|4|5|6... Next

Not certain as to what you mean but I'm pretty sure there is a good
article on building next/prev links on phpbuilder.com
- -- 
Nick Wilson //  www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8zngFHpvrrTa6L5oRAthSAKCba5wRtMJE4V1asHmYJCyWSBUeUACfXSkq
AZT8lfMLG9lsRx31jnXyyNA=
=226P
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Page Numbers

2002-04-30 Thread Pekka Saarinen

At 4/30/2002, you wrote:
Any one know how to display, go to page number on a record list page

eg

Prev 1|2|3|4|5|6... Next

Here's a very simplified demo of dropdown+arrows paging code I did for my 
gallery software.
It might not be the most clever code around, but it works, and scales well.

All you need to edit is the main query, couple fo arrow images, and 
database connect code to make it run.  It now feeds itself, so you might 
want to change that, too.
Live demo is e.g. http://photography-on-the.net/gallery/list.php?exhibition=1

--

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
 titlePaging demo by P.S./title
/head
body

?php
// total has to be a value queried from database (=how many results?),
// but to make this code shorter let's give it some value for this demo:
$total = 122;
// set global SERVER variable for different versions of PHP
if (isset($_SERVER)) $PHP_SELF = $_SERVER['PHP_SELF'];

// connect to the database with this file:
include (connect.php);

if (isset  ($HTTP_POST_VARS['perpage']))
{$perpage = $HTTP_POST_VARS['perpage'];
}
if (isset ($HTTP_POST_VARS['offset']))
{$offset = $HTTP_POST_VARS['offset'];
}
if (isset  ($HTTP_GET_VARS['perpage']))
{$perpage = $HTTP_GET_VARS['perpage'];
}
if (isset ($HTTP_GET_VARS['offset']))
{$offset = $HTTP_GET_VARS['offset'];
}
if (!isset ($perpage))
{$perpage = 10;
}
if (!isset ($offset))
{$offset = 0;
}

$fetchlist = mysql_query(

SELECT
 *
FROM
 your_table
LIMIT
 $offset,$perpage

 );
if (!$fetchlist) {
 $queryname = fetchlist;
 include(db_error.php);
}
?

FORM ACTION=?php echo($PHP_SELF); ? METHOD=POST 
name=FORM_page_change id=FORM_page_change
input type=hidden name=offset value=?php print $offset; ?
input type=hidden name=perpage value=?php print $perpage; ?
input type=hidden name=JS_SUBMIT_page_change value=yep
table border=0 cellspacing=3 
cellpadding=0trtdnbsp;nbsp;/tdtd?php

// PREV PAGE LINK WITH VERIFICATION
$prevlink = $offset-$perpage;
if ($prevlink=0) $prevlink=0;
print a href=\ . $PHP_SELF;
print ?offset= . $prevlink . perpage= . $perpage;
print \img src=\../graphs/left.gif\ width=\14\ hspace=\1\ 
height=\16\ border=\1\ alt=\previous page\/a;
print /tdtd;
print select name=\offset\ onchange=\function_submit_page_change()\ 
style=\border: 0px none;\;
print \r;


// THIS CODE BUILDS THE DROPDOWN MENU FOR PAGE SELECTION
$page = 1;
for ($i=0; $i=$total-1; )
{
 print option value=\;
 print $i;
 print \;
 if ($offset==$i) {print  selected;}
 print Page ;
 print $page . nbsp; ;
 print /option;
 print \r;
 $i=$i+$perpage;
 $page++;
}
print /select;
print \r;
print /tdtd;


// NEXT PAGE LINK WITH VERIFICATION
$nextlink = $offset+$perpage;
if ($nextlink=$total) $nextlink=$offset;
if ($nextlink=0) $nextlink=0;
print a href=\ . $PHP_SELF;
print ?offset= . $nextlink . perpage= . $perpage;
print \img src=\../graphs/right.gif\ width=\14\ height=\16\ 
border=\1\ alt=\next page\/a;
print /tdtd;


// JAVASCRIPT FOR THIS FORM
?
script language=JavaScript type=text/javascript
!--
function function_submit_page_change(){
document.FORM_page_change.submit();
 }
//--
/script
noscript
?php
//NON JAVASCRIPT MENU FOR BROWSERS WITHOUT JAVASCRIPT
print input type=\image\ src=\../graphs/jump_to.gif\ alt=\jump to 
selected page\ name=\SUBMIT_page_change\;
?
/noscript

/td/tr/table

?php
Print pbYou successfully listed results from  . $offset .  to  . 
($offset+$perpage) . /b;
?

/body
/html

--

Cheers,
Pekka
http://photography-on-the.net/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Page Numbers

2002-04-30 Thread Pekka Saarinen

At 4/30/2002, you wrote:
At 4/30/2002, you wrote:
Any one know how to display, go to page number on a record list page

eg

Prev 1|2|3|4|5|6... Next

Here's a very simplified demo of dropdown+arrows paging code I did for my 
gallery software.
It might not be the most clever code around, but it works, and scales well.

All you need to edit is the main query, couple fo arrow images, and 
database connect code to make it run.  It now feeds itself, so you might 
want to change that, too.
Live demo is e.g. http://photography-on-the.net/gallery/list.php?exhibition=1

--

Damn, the code went corrupt on mailing. Can anyone tell how to post full 
code samples here?
You can get the code by viewing html source of
http://photography-on-the.net/gallery/pagingdemo.html
The code runs at http://photography-on-the.net/gallery/pagingdemo.php

Pekka


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php