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

PHP & Base de données Discussion :

comment Créer un système de pagination automatique


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Homme Profil pro
    Webdesigner
    Inscrit en
    Juin 2015
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Webdesigner
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2015
    Messages : 8
    Par défaut comment Créer un système de pagination automatique
    Bonjour,

    j’armai bien savoir comment Créer un système de pagination automatique en PHP

    J'ai reussi a créer le système avec php on utilisant un serveur local easyphp 1.8 mais lorsque j'ai installer la dernière version d'easyphp qui support le PDO Mon code de PHP ne fonctionne pas

    je pense que mon code ne fonctionnait pas sur PHP5

    voila mon 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
    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
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    <?
    session_start();
    include"conn.php";
    $login=$_SESSION['login'];
    $password=$_SESSION['password'];
    if($login){
    $sql="select * from administration ";
    $result=mysql_query($sql);
     
    $sqll="select * from administration ";
    $resultt=mysql_query($sqll);
    ?>
    <?
    function barre_navigation ($nb_total,$nb_affichage_par_page,$debut,$nb_liens_dans_la_barre) {
        $barre = '';
     
        if ($_SERVER['QUERY_STRING'] == "") {
            $query = $_SERVER['PHP_SELF'].'?debut=';
        }
        else {
            $tableau = explode ("debut=", $_SERVER['QUERY_STRING']);
            $nb_element = count ($tableau);
            if ($nb_element == 1) {
                $query = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&debut=';
            }
            else {
                if ($tableau[0] == "") {
                    $query = $_SERVER['PHP_SELF'].'?debut=';
                }
                else {
                    $query = $_SERVER['PHP_SELF'].'?'.$tableau[0].'debut=';
                }
            }
        }
     
        $page_active = floor(($debut/$nb_affichage_par_page)+1);
        $nb_pages_total = ceil($nb_total/$nb_affichage_par_page);
     
        if ($nb_liens_dans_la_barre%2==0) {
            $cpt_deb1 = $page_active - ($nb_liens_dans_la_barre/2)+1;
            $cpt_fin1 = $page_active + ($nb_liens_dans_la_barre/2);
        }
        else {
            $cpt_deb1 = $page_active - floor(($nb_liens_dans_la_barre/2));
            $cpt_fin1 = $page_active + floor(($nb_liens_dans_la_barre/2));
        }
     
        if ($cpt_deb1 <= 1) {
            $cpt_deb = 1;
            $cpt_fin = $nb_liens_dans_la_barre;
        }
        elseif ($cpt_deb1>1 && $cpt_fin1<$nb_pages_total) {
            $cpt_deb = $cpt_deb1;
            $cpt_fin = $cpt_fin1;
        }
        else {
            $cpt_deb = ($nb_pages_total-$nb_liens_dans_la_barre)+1;
            $cpt_fin = $nb_pages_total;
        }
     
        if ($nb_pages_total <= $nb_liens_dans_la_barre) {
            $cpt_deb=1;
            $cpt_fin=$nb_pages_total;
        }
     
        if ($cpt_deb != 1) {
            $cible = $query.(0);
            $lien = '<A HREF="'.$cible.'" class=b>&lt;&lt;</A>&nbsp;&nbsp;';
        }
        else {
            $lien='';
        }
        $barre .= $lien;
     
        for ($cpt = $cpt_deb; $cpt <= $cpt_fin; $cpt++) {
            if ($cpt == $page_active) {
                if ($cpt == $nb_pages_total) {
                    $barre .= $cpt;
                }
                else {
                    $barre .= $cpt.'&nbsp;-&nbsp;';
                }
            }
            else {
                if ($cpt == $cpt_fin) {
                    $barre .= "<A HREF='".$query.(($cpt-1)*$nb_affichage_par_page);
                    $barre .= "' class=b>".$cpt."</A>";
                }
                else {
     
                    $barre .= "<A HREF='".$query.(($cpt-1)*$nb_affichage_par_page);
                    $barre .= "' class=b>".$cpt."</A>&nbsp;-&nbsp;";
                }
            }
        }
     
        $fin = ($nb_total - ($nb_total % $nb_affichage_par_page));
        if (($nb_total % $nb_affichage_par_page) == 0) {
            $fin = $fin - $nb_affichage_par_page;
        }
     
        if ($cpt_fin != $nb_pages_total) {
            $cible = $query.$fin;
            $lien = '&nbsp;&nbsp;<A HREF="'.$cible.'" class=b>&gt;&gt;</A>';
        }
        else {
            $lien='';
        }
        $barre .= $lien;
     
        return $barre;   
    }
     
    $vs="select * from club ORDER BY id DESC";
    $rs=mysql_query($vs) or die('Erreur SQL !<br>'.$vs2.'<br>'.mysql_error()); 
    $nb_total=mysql_num_rows($rs);
    if (!isset($_GET['debut'])) $_GET['debut'] = 0;
    $nb_affichage_par_page =6 ;
    $vs2="select * from club ORDER BY id DESC LIMIT ".$_GET['debut'].",".$nb_affichage_par_page;
    $rs2=mysql_query($vs2) or die('Erreur SQL !<br>'.$vs2.'<br>'.mysql_error());
     
    while ($row=mysql_fetch_array($rs2)){
    if (!isset($bg)|| $bg=='#7F7F7F') {
              $bg ='#B5B5B5';
              }
              else { $bg='#7F7F7F'; }
    ?>
    <html>
    <head>
    <title>maq1</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/stylemenu.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="engine1/style.css" />
        <script type="text/javascript" src="engine1/jquery.js"></script>
    <style type="text/css">
    <!--
    body {
        background-image: url(images/bg.jpg);
        background-repeat: no-repeat;
        background-position:center;
        background-attachment:fixed;
    }
    .d {    font-family: Arial, Helvetica, sans-serif, "Century Gothic";
        font-size: 14px;
        color: #0E63B4;
        font-weight: bold;
        text-align: center;
    }
    .d {    text-align: center;
        font-weight: normal;
    }
    .style15 {  color:#000;
        font-family:Arial, Helvetica, sans-serif;
        font-size:12px;
    }
    .style16 {  color: #d70404
    }
    .style17 {font-family: "Century Gothic";
        font-weight: bold;
        color:#000;
    }
    .style18 {  color: #000;
    }
    .style19 {color: #ffcc9e; font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
    .stylea1 {font-family: Arial;
     
        font-size: 12px;
        color:#000000;
    }
    .stylea6 {font-family: Arial;
        font-weight: bold;
        font-size: 14px;
        color: #2a5580;
    }
    -->
    </style></head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <!-- Save for Web Slices (maq1.jpg) -->
    <table width="958" height="1291" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
        <tr>
            <td height="186"><table width="958" height="186" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><img src="images/ban.jpg" width="958" height="186"></td>
              </tr>
            </table></td>
        </tr>
        <tr>
            <td height="52"><table width="958" height="38" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><div id="menu"><div id='cssmenu'>
    <ul>
       <li><a href='index.html'><span>ACCUEIL</span></a>
          </li>
       <li><a href='presentation.html'><span>QUI SOMME NOUS ?</span></a>
       </li>
     
       <li  class='has-sub'><a href='#'><span>EL JADIDA</span></a>
       <ul>
             <li><a href='historique.html'><span>HISTORIQUE</span></a>
             </li>
             <li><a href='plan.html'><span>PLAN</span></a>
             </li>
          </ul>
       </li>
     
     
      <li class='has-sub'><a href='#'><span>Médiathèque</span></a>
          <ul>
             <li><a href='photos.html'><span>PHOTOS</span></a>
             </li> 
             <li><a href='videos.html'><span>VIDEOS</span></a>
             </li>       
          </ul>
       </li>
       <li class='last'><a href='contact.html'><span>CONTACT</span></a></li>
    </ul>
                </div></div></td>
              </tr>
            </table></td>
        </tr>
        <tr>
            <td height="263"><table width="958" height="263" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="263" valign="top"><div id="slider">
    <div id="wowslider-container1">
        <div class="ws_images"><ul>
            <li><img src="data1/images/1.jpg" alt="1" title="Tbourida : L'art équestre marocain" id="wows1_0"/></li>
            <li><a href="http://wowslider.com/vf"><img src="data1/images/2.jpg" alt="full screen slider" title="Oualidia. Une petite ville à découvrir ou redécouvrir" id="wows1_1"/></a></li>
            <li><img src="data1/images/3.jpg" alt="3" title="La cité portugaise, toute une histoire" id="wows1_2"/></li>
        </ul></div>
        <div class="ws_bullets"><div>
            <a href="#" title="1"><img src="data1/tooltips/1.jpg" alt="Tbourida : L'art équestre marocain"/>1</a>
            <a href="#" title="full screen slider"><img src="data1/tooltips/2.jpg" alt="Oualidia. Une petite ville à découvrir ou redécouvrir"/>2</a>
            <a href="#" title="3"><img src="data1/tooltips/3.jpg" alt="La cité portugaise, toute une histoire"/>3</a>
        </div></div>
        <div class="ws_shadow"></div>
        </div>   
        <script type="text/javascript" src="engine1/wowslider.js"></script>
        <script type="text/javascript" src="engine1/script.js"></script>
                </div></td>
              </tr>
            </table></td>
        </tr>
        <tr>
            <td height="253" valign="top"><table width="958" height="653" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="653" valign="top">&nbsp;
                  <table width="900" height="384" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="17" height="365" valign="top">&nbsp;</td>
                      <td width="613" valign="top"><table width="900" height="372" border="0" align="center" cellspacing="0">
                        <tr>
                          <td width="591" height="36" class="style16"><div align="center"></div></td>
                        </tr>
                        <tr>
                          <td><p class="Style44"><span class="style1">
     
                            </span></p>
                            <table width="900" border="0" cellpadding="0" cellspacing="0">
                              <tr>
                                <td width="8">&nbsp;</td>
                                <td width="328"><span class="style16"><? echo ''.$row['nom'].''; ?></span></td>
                              </tr>
                            </table>
                            <table width="900" height="114" border="0" align="left" cellpadding="0" bordercolor="#CCCCCC">
                              <tr>
                                <td width="12" rowspan="3" align="left" valign="top">&nbsp;</td>
                                <td colspan="2" valign="top" class="style48"><span class="style15"><span class="style16"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Le : <? echo ''.$row['telephone'].''; ?></span></span></td>
                              </tr>
                              <tr>
                                <td width="898" colspan="2" valign="top" class="style48"><div align="justify" class="style15">
                                  <table width="900" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                      <td width="113"><img src="<? echo ''.$row['photo'].''; ?>" width="100" height="100"></td>
                                      <td width="587" valign="top"><span class="stylea1"><? echo substr($row['adresse'],0,400); ?></span></td>
                                      </tr>
                                    </table>
                                  </div>
                                  <div align="justify"><span class="style15"><span class="style16"><span class="style17"><span class="style18"></span></span></span></span><span class="style15"></span></div></td>
                              </tr>
                              <tr>
                                <td height="14" align="right" valign="bottom"><script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script>
                                  <table width="110" border="0" align="right" cellpadding="0" cellspacing="0">
                                    <tr>
                                      <td width="151"><span class="style68 style18"><a href="modifier_article.php?iid=<? echo ''.$row['id'].''; ?>" class="style15">Modifier</a></span></td>
                                      <td width="49"><span class="style19"><a href="supprimer_article.php?iid=<? echo $row['id']; ?>">Supprimer</a></span></td>
                                    </tr>
                                  </table>
                                  <span class="style1">&nbsp;</span></td>
                              </tr>
                              <tr>
                                <td align="left" valign="top">&nbsp;</td>
                                <td height="14" align="right" valign="bottom">&nbsp;</td>
                              </tr>
                              <tr>
                                <td align="left" valign="top">&nbsp;</td>
                                <td height="14" align="center" valign="bottom">-----------------------------------------------------------------------------------------</td>
                              </tr>
                            </table>
                            <span class="style1">
                              <? }?>
                            </span></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td></td>
                        </tr>
                        </table></td>
                    </tr>
                    <tr>
                      <td width="17" align="center" class="styled57">&nbsp;</td>
                      <td align="center"><span class="styled57"><span class="stylea6"><? echo ''.barre_navigation($nb_total, $nb_affichage_par_page, $_GET['debut'], 6).''; ?></span></span></td>
                    </tr>
                </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
            <td><table width="958" height="158" border="0" cellspacing="0" cellpadding="0" background="images/maq1_06.png">
              <tr>
                <td>&nbsp;</td>
              </tr>
            </table></td>
        </tr>
    </table>
    <!-- End Save for Web Slices -->
    </body>
    </html>
    <?
    } else {
    ?>
    <script language="javascript">
    location.href='../admin.php'>
    </script>
    <? } ?>

    Image D'erreur : http://www.m5zn.com/newuploads/2015/...047bac3cc5.png

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Utilise <?php et non <?

    Au passage tu as deux fois la même requête ligne 7 et ligne 10.

    Et les decoupages que tu fais sur $_SERVER['QUERY_STRING']) c'est tout simplement l'apocalypse.
    Les données dans l'URL sont accessibles par $_GET, il n'y a pas besoin de découper sois même l'URL.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre habitué
    Homme Profil pro
    Webdesigner
    Inscrit en
    Juin 2015
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Webdesigner
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2015
    Messages : 8
    Par défaut
    j'ai ce message sur la ligne

    Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\GeoSport\backoffice\club.php on line 233

    $rs=mysql_query($vs) or die('Erreur SQL !<br>'.$vs2.'<br>'.mysql_error());

  4. #4
    Responsable Systèmes


    Homme Profil pro
    Gestion de parcs informatique
    Inscrit en
    Août 2011
    Messages
    18 259
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Gestion de parcs informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Août 2011
    Messages : 18 259
    Par défaut
    Le message est clair. La fonction mysql_query est dépréciée, ce qui signifie obsolète. C'est un warning, tu peux encore l'utiliser (et ne plus voir les messages en les désactivant) mais tu n'as aucune garantie qu'elle soit encore présente dans les prochaines versions/ Maintenant on utilise PDO.

    http://php.developpez.com/faq/?page=pdo
    Ma page sur developpez.com : http://chrtophe.developpez.com/ (avec mes articles)
    Mon article sur le P2V, mon article sur le cloud
    Consultez nos FAQ : Windows, Linux, Virtualisation

  5. #5
    Membre habitué
    Homme Profil pro
    Webdesigner
    Inscrit en
    Juin 2015
    Messages
    8
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Webdesigner
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2015
    Messages : 8
    Par défaut
    Oui Oui j'ai bien compris le message
    mais comment le désactivé ou bien quelle est l’équivalent de cette fonction et merci d'avance

  6. #6

Discussions similaires

  1. [XL-2010] Comment créer un système de licence en VBA sur Excel ?
    Par ben5622 dans le forum Conception
    Réponses: 113
    Dernier message: 09/06/2019, 11h50
  2. Réponses: 2
    Dernier message: 21/09/2017, 17h55
  3. Comment créer un systéme d'exploitation ?
    Par vermersch.vermersch2 dans le forum Autres systèmes
    Réponses: 2
    Dernier message: 19/09/2013, 15h21
  4. Créer un système de pagination
    Par benny-blanco dans le forum C#
    Réponses: 2
    Dernier message: 22/09/2012, 19h17
  5. Comment créer un Système multi-station
    Par Vendelin dans le forum Ordinateurs
    Réponses: 4
    Dernier message: 21/01/2009, 16h26

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