IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

Script de pagination PHP


Sujet :

EDI, CMS, Outils, Scripts et API PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2018
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2018
    Messages : 2
    Par défaut Script de pagination PHP
    Bonjour tous le monde.

    j ai besoin de votre aide svp , j ai un problème avec mon script PHP sur la partie des pages, j essaye de faire suivant mais le code que j ai me donne la dernier page au lieu de la suivante et même chose pour la page précédente ca me donne la première page , si vous pouvez m aidez a trouver l erreur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    /* Paging */
    	$paging = '<div class="paging">'."\n";
    	$paging .= '<a href="offre.php?page=0&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'"" class="paging-blue"><</a>';
    	for($x=$page;$x<($page+5);$x++)
    	{
    		if($x < $totalPage)
    		{
    			if($page == $x)
    			{
    				$paging .= '<a href="offre.php?page='.$x.'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'" class="paging-blue pageselected">'.($x+1).'</a>'."\n";
    			}
    			else
    			{
    				$paging .= '<a href="offre.php?page='.$x.'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'" class="paging-blue">'.($x+1).'</a>'."\n";
    			}
    		}
    	}
    	$paging .= '<a href="offre.php?page='.($totalPage-1).'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'"" class="paging-blue">></a>';
    	$paging .= '</div>'."\n";
     
    	$class_templateloader->assign("{paging}",$paging);
     
    	$class_templateloader->show();
     
    }
    else
    {
    	if($isConnected)
    	{
    		$class_templateloader->loadTemplate("template/tpl/offre.tpl");
    		$class_templateloader->assign("{searchtext}",$searchtext);
    		$class_templateloader->assign("{block_resultat}",$block_resultat);
    		$class_templateloader->assign("{publicite_top}",$publicite_top);
    		$class_templateloader->assign("{categorie}",$all_categorie);
    		$class_templateloader->assign("{departement}",$all_region);
    		$class_templateloader->assign("{prix}",$all_tri);
    		$class_templateloader->assign("{titleannonce}",$titleAnnonce);
     
    		/* Paging */
    		$paging = '<div class="paging">'."\n";
    		$paging .= '<a href="offre.php?page=0&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'"" class="paging-blue"><</a>';
    		for($x=$page;$x<($page+5);$x++)
    		{
    			if($x < $totalPage)
    			{
    				if($page == $x)
    				{
    					$paging .= '<a href="offre.php?page='.$x.'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'" class="paging-blue pageselected">'.($x+1).'</a>'."\n";
    				}
    				else
    				{
    					$paging .= '<a href="offre.php?page='.$x.'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'" class="paging-blue">'.($x+1).'</a>'."\n";
    				}
    			}
    		}
    		$paging .= '<a href="offre.php?page='.($totalPage-1).'&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal.'"" class="paging-blue">></a>';
    		$paging .= '</div>'."\n";
     
    		$class_templateloader->assign("{paging}",$paging);
     
    		$class_templateloader->show();
    	}
    	else
    	{
    		$class_templateloader->loadTemplate("template/tpl/limited.tpl");
    		$class_templateloader->show();
    	}
    }

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    • 1ere page : 1
    • Précédente : $page - 1
    • Suivante : $page + 1
    • Dernière : $totalPage


    Dernière modification par Invité ; 19/08/2018 à 11h03.

  3. #3
    Invité
    Invité(e)
    Par défaut
    [EDIT] En relisant ton code, il semble que le paramètre "page" commencent à 0... !
    Alors :
    • 1ere page : 0
    • Précédente : $page - 1
    • Suivante : $page + 1
    • Dernière : $totalPage-1

    Ce qui donne (en optimisant un peu ton code :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    	/* Paging */
    	$paging = '<div class="paging">'."\n";
     
    	$extraParams = '&categorie='.$categorie.'&searchtext='.$searchtext.'&departement='.$departement_code.'&tri='.$tri.'&codepostal='.$codepostal;
     
    	if( $page!=0 )
    	{
    		$paging .= '<a href="offre.php?page=0'.$extraParams.'" class="paging-blue">&lt;</a>'; // première
    	}
    	if( $page>0 )	
    	{
    		$paging .= '<a href="offre.php?page='.max($page-1,0).$extraParams.'" class="paging-blue">&lt;</a>'; // précédente
    	}
    	for($x=$page;$x<($page+5);$x++)
    	{
    		if($x < $totalPage)
    		{
    			if($page == $x)
    			{
    				$paging .= '<a href="offre.php?page='.$x.$extraParams.'" class="paging-blue pageselected">'.($x+1).'</a>'."\n";
    			}
    			else
    			{
    				$paging .= '<a href="offre.php?page='.$x.$extraParams.'" class="paging-blue">'.($x+1).'</a>'."\n";
    			}
    		}
    	}
    	if( $page<($totalPage-1) )	
    	{
    		$paging .= '<a href="offre.php?page='.min($page+1,$totalPage-1).$extraParams.'" class="paging-blue">&gt;</a>'; // suivante
    	}
    	if( $page!=($totalPage-1) )	
    	{
    		$paging .= '<a href="offre.php?page='.($totalPage-1).$extraParams.'" class="paging-blue">&gt;&gt;</a>'; // dernière
    	}
     
    	$paging .= '</div>'."\n";

  4. #4
    Nouveau candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2018
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2018
    Messages : 2
    Par défaut
    Merci bcp pour votre réponse , j ai essayer les modif mais ca marche pas

  5. #5
    Invité
    Invité(e)
    Par défaut
    Avec "ca marche pas", on n'ira pas loin....


    As-tu au moins regardé le code HTML généré ?

Discussions similaires

  1. Probleme Script PHP verification 2 champs
    Par superthx dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 1
    Dernier message: 29/04/2013, 19h01
  2. problem script php
    Par ranoucha dans le forum Langage
    Réponses: 1
    Dernier message: 07/11/2009, 23h07
  3. [EasyPHP] probleme script php/MySQL
    Par daninou dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 2
    Dernier message: 06/01/2008, 14h31
  4. Probleme script PHP/MySQL
    Par boo64 dans le forum Requêtes
    Réponses: 24
    Dernier message: 28/04/2006, 15h36
  5. A l'aide svp j'ai de gros problemes sur un script php
    Par schtek2 dans le forum Langage
    Réponses: 1
    Dernier message: 24/04/2006, 01h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo