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

Langage PHP Discussion :

numéro de pagination [PHP 5.3]


Sujet :

Langage PHP

  1. #1
    Candidat au Club
    Femme Profil pro
    Technicien Help Desk
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut numéro de pagination
    bonjour tout le monde
    j'affiche des informations a partir la base de données avec la pagination mais j'ai des milles des lignes alors il affiche les numéros des page jusqu’a qui il sort de la Template
    merci bien de m'aider pour qu'il peut sauter la ligne après la page 38
    Images attachées Images attachées  

  2. #2
    Candidat au Club
    Femme Profil pro
    Technicien Help Desk
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut numéro de pagination
    j'ai oublie le code bon le voila
    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
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    <?php
    session_start();
    include_once('cnx.php');
    $date = date("d-m-Y");
    $heure = date("H:i");
    include_once('head.php');
    ?>
    	<div id="menu2">
      </div>
      <div id="page">
    	<h1>Liste des Mareyeurs</h1>
    	  <?php
    function getPage($stmt, $pageNum, $rowsPerPage)
    {
    	$offset = ($pageNum - 1) * $rowsPerPage;
    	$rows = array();
    	$i = 0;
    	while(($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC, SQLSRV_SCROLL_ABSOLUTE, $offset + $i)) && $i < $rowsPerPage)
    	{
    		array_push($rows, $row);
    		$i++;
    	}
    	return $rows;
    }
    // Set the number of rows to be returned on a page.
    $rowsPerPage =25;
     
    // Connect to the server.
    set_time_limit(0);
    include_once('cnx.php');
    if (!$conn)
    	die( print_r( sqlsrv_errors(), true));
        set_time_limit(0);
     
     
     $sql = "select * from V_Carte_Mar where Extrait is NULL";
     
    $stmt = sqlsrv_query($conn, $sql, array(), array( "Scrollable" => 'static' ));
    $num = sqlsrv_num_rows($stmt);
    if ( !$stmt )
    	die( print_r( sqlsrv_errors(), true));
     
    // Get the total number of rows returned by the query.
    // Display links to "pages" of rows.
    $rowsReturned = sqlsrv_num_rows($stmt);
    if($rowsReturned === false){
        die( print_r( sqlsrv_errors(), true));
     
       echo "No rows returned.";
    	exit();
    	}
    else
    {     
        // Display page links.
        $numOfPages = ceil($rowsReturned/$rowsPerPage);
        for($i = 1; $i<=$numOfPages; $i++)
        {
            $pageLink = "?pageNum=$i";
            print("<a href=$pageLink>$i</a>&nbsp;&nbsp;");
        }
        echo "<br/><br/>";
    }
    // Display the selected page of data.
    echo "<table class='table2' border='1px'>
    <tr>
    <th>Racine</th>
    <th>Nom</th>
    <th width='1900'>Prenom</th>
    <th>Type_Ref</th>
    <th width='5000'>Raison_Sociale</th>
    <th>Num_CIN</th>
    <th>Série_Carte</th>
    <th>Consulter Representant</th>
    
    </tr>";
     
    $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
    $page = getPage($stmt, $pageNum, $rowsPerPage);
     
    foreach($page as $row)																												
     echo "<tr>
     <td>$row[1]</td>
     <td>$row[9]</td>
     <td width='1900'>$row[10]</td>
     <td>$row[2]</td>
     <td width='5000'>$row[3]</td>
     <td>$row[8]</td>
     <td>$row[11]</td>
     <td><a href=\"Afficher_Representant.php?id=$row[1]\" target=\"_blank\">Consulter</a></td>
     </tr>";
    //<td>if ($row[2]=='m'){ "echo 'Société' "} else { "echo 'Personne Physique' "}</td>
    echo "</table>";
    echo "<br/>";
    if($pageNum > 1)
    {
    	$prevPageLink = "?pageNum=".($pageNum - 1);
    	echo "<a href='$prevPageLink'>Previous Page</a>";
    }
     
    // Display Next Page link if applicable.
    if($pageNum < $numOfPages)
    {
    	$nextPageLink = "?pageNum=".($pageNum + 1);
    	echo "&nbsp;&nbsp;<a href='$nextPageLink'>Next Page</a>";
    }
     
    // Display Previous Page link if applicable.
     
     //<td><a href=\"getuser.php?q=$row[1]\">Consulrer Representant</a></td>
    sqlsrv_close( $conn );
    ?>
    </div>
     
    </div>
    </body>
    </html>
    merci beaucoup

  3. #3
    Expert confirmé Avatar de papajoker
    Homme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2013
    Messages
    2 190
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2013
    Messages : 2 190
    Points : 4 627
    Points
    4 627
    Par défaut
    bonjour
    ici, j'affiche que les 10 premiers et 10 derniers si + de 30 pages
    ligne 55 de ton code
    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
    $first=true;
    $numOfPages = ceil($rowsReturned/$rowsPerPage);
        for($i = 1; $i<=$numOfPages; $i++)   {
            $pageLink = "?pageNum=$i";
    		if ($numOfPages>30) {
    			if (($i>10) && ($i<$numOfPages-10)) {
    				if ($first){
    				 echo '&nbsp;.&nbsp;.&nbsp;.&nbsp;';
    				 $first=false;
    				}
    			}
    			else  print("<a href=$pageLink>$i</a>&nbsp;&nbsp;");
    		}
    		else  print("<a href=$pageLink>$i</a>&nbsp;&nbsp;");
        }
    -------------
    edit : oui mon code ne répond pas a ta demande
    $moi= ( !== ) ? : ;

  4. #4
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2013
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Distribution

    Informations forums :
    Inscription : Octobre 2013
    Messages : 24
    Points : 33
    Points
    33
    Par défaut
    Bonjour,

    Je ne sais pas si ca peux t'aider de cette manière mais une solution pourrais être
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    if($i%38 == 0)
                   print("<br>");


    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
     
    else
    {     
        // Display page links.
        $numOfPages = ceil($rowsReturned/$rowsPerPage);
        for($i = 1; $i<=$numOfPages; $i++)
        {
            $pageLink = "?pageNum=$i";
            print("<a href=$pageLink>$i</a>&nbsp;&nbsp;");
     
            if($i%38 == 0)
                   print("<br>");
        }
        echo "<br/><br/>";
    }

  5. #5
    Candidat au Club
    Femme Profil pro
    Technicien Help Desk
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut probléme pagination
    ca marche mais il a pas régler le problème car quand il arrive a la page 73 il termine
    Images attachées Images attachées  

  6. #6
    Expert confirmé Avatar de papajoker
    Homme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2013
    Messages
    2 190
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2013
    Messages : 2 190
    Points : 4 627
    Points
    4 627
    Par défaut
    ici centré

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    else
    {     
        // Display page links.
        echo '<div style="text-align:center;">';
        $numOfPages = ceil($rowsReturned/$rowsPerPage);
        for($i = 1; $i<=$numOfPages; $i++)
        {
            print('<a href="?pageNum='.$i.'">'.$i.'</a>&nbsp; ');
             //if($i%36 == 0)               print("<br />");
        }
        echo "</div><br />";
    $moi= ( !== ) ? : ;

  7. #7
    Candidat au Club
    Femme Profil pro
    Technicien Help Desk
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut probléme pagination
    merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MySQL] Limité les numéros de page (pagination)
    Par dancom5 dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 09/12/2011, 08h21
  2. Pagination avec (Next,Prev) et numéros
    Par siimpatiico dans le forum VB.NET
    Réponses: 3
    Dernier message: 15/07/2008, 22h28
  3. Réponses: 3
    Dernier message: 31/08/2007, 18h31
  4. récuperation d'un numéro de téléphone
    Par herzleid dans le forum Delphi
    Réponses: 4
    Dernier message: 17/07/2007, 09h25
  5. Calcul des numéros de semaine d'un calendrier
    Par Invité dans le forum Algorithmes et structures de données
    Réponses: 4
    Dernier message: 06/11/2002, 21h29

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