PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Implementing paging
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Implementing paging

Réponse
 
LinkBack Outils de la discussion
Vieux 11/03/2008, 17h03   #1
nostradumbass77@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Implementing paging


What is the best way to implement paging through database results? Say
there are two hyperlinks NEXT and PREV on the page.

I am stumped, would like to know how to proceed from here.

Should a global variable that keeps track of the results page number
be used? What else is required? What if I want to use a POST method
and not a GET? How do I do that?

Any appreciated!
  Réponse avec citation
Vieux 11/03/2008, 21h05   #2
Mason Barge
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Implementing paging


<nostradumbass77@yahoo.com> wrote in message
news:f507a0c3-9c42-4895-b486-1ff2a75d0ae7@s12g2000prg.googlegroups.com...
>
> What is the best way to implement paging through database results? Say
> there are two hyperlinks NEXT and PREV on the page.
>
> I am stumped, would like to know how to proceed from here.
>
> Should a global variable that keeps track of the results page number
> be used? What else is required? What if I want to use a POST method
> and not a GET? How do I do that?
>
> Any appreciated!


Wow. Okay, first, I'm not a PHP expert, but I have done some pagination.

The best I can think, the way to use POST would be to use a submit button
with a hidden variable value for the "next" link. Or you could use
if you don't mind requiring them.

The only way I've done it is using a GET value to change the WHERE values in
the query . You just need to set some variables: $perpage - Number of
returns per page (which can be a constant or which you can let the user
choose); a GET value; a $pages value for the number of pages; what I call
$batch which determines the number by which to multiply the $perpage to set
the result.

Here's a code snippet to give you an idea of what I did:
$a = ($batch + 1);
$b = $batch + ($limit);
if ($b > $numrows) $b = $numrows;
$pages=ceil($numrows/$limit);

if ($batch>=1) {
$prevbatch=($batch-$limit);
}

$currentpage = (($batch/$limit) + 1);

It's not hard to do in terms of PHP knowledge, but it takes a bit of
ingenuity. It's a bit of fun coding that a non-guru can accomplish.

Another idea would be to hold the values in an array, but you'd have to use
a user-side script to change the displayed values.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h11.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10821 seconds with 10 queries