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
|
<?php
$nbParPage = 5;
?>
<head>
<form action="Demandes_doc.php" method="GET">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ITM</th>
<th>id_prospect</th>
<th>Nom Prenom</th>
<th>Societe</th>
<th>Date</th>
<th style="color:red">Demande</th>
<th>Stock</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
require 'connect.inc.php';
if(isset($_GET['orderby']) && $_GET['orderby'] == ("date_maj" || "nom")) $orderby=$_GET['orderby'];
else $orderby="date_maj";
if(isset($_GET['nom']))
$tri="ASC";
else $tri="DESC";
$req1=mysql_query("SELECT demande_publications.id, demande_publications.code_publication, demande_publications.id_prospect, demande_publications.date_maj, documentation.code_publication_doc, documentation.description, documentation.qte_stock, documentation.qte_demande, prospects.id_prospect, prospects.nom, prospects.prenom, prospects.societe
FROM demande_publications, documentation, prospects
WHERE demande_publications.id_prospect = prospects.id_prospect AND demande_publications.code_publication = documentation.code_publication_doc
ORDER BY ' . $orderby'");
$nbNews=mysql_numrows($req1);
echo "il y a $nbNews";
while ($item = mysql_fetch_array($req1))
{
echo '<tr>';
$code_publication_doc = $item['code_publication_doc'];
echo '<a class="btn btn-danger" href="delete_demandedoc.php?id='.$item['id'].'&qte_stock='.$item['qte_stock'].'&stock_a_jour='.$stock_a_jour.'&qte_demande='.$item['qte_demande'].'&code_publication='.$item['code_publication'].'&code_publication_doc='.$item['code_publication_doc'].'"><span class="glyphicon glyphicon-remove"></span> Supprimer </a>';
echo '</td>';
echo '</tr>';
}
mysql_close();
//On calcule le nombre de numéro à afficher en fonction du nombre de news par
//page en arrondissant au nombre supérieur grace a la fonction ceil.
$moy= ceil($nbNews/$nbParPage);
echo "<br>et il y aura $moy page<br>";
//*********** Partie concernant le "bouton" précedent ***********\\
//on vérifie qu'il y a au minimum 2 page a afficher pour utiliser
//la fonction Suivant / précédent
if ($moy>=2)
{
//on vérifie l'éxistence de la variable page avant les vérifications
if (isset($_GET['page']))
{
//si $_GET['page'] = 1 alors on est a la première page et donc pas besoins
//de lien vers la précédente qui n'éxiste pas
if ($_GET['page']==1){echo "Precedent ";}
//sinon on met le lien en ajoutant +1 page a la page courante
else
{
echo "<a href=\"Demandes_doc_test_pagination.php?page=".($_GET['page']-1)."\">Precedent</a> ";
}
}
else{echo "Precedent ";}
}
//*********** fin de la partie concernant le "bouton" précedent ***********\\
//prenons un exemple concret :
// nous avons 10 news dans la base
// a ce moment nous savons donc qu'il y aura 2 page :
// $nbNews = 10 divisé par 5 ( 5 news par page ) = 2 pages.
// on peut déja afficher les numéros :
// on effectue une boucle tant qu'il y a des pages on ajoute un lien
for ($i=0;$i<$moy;$i++)
{
// on ajoute 1 a $i pour afficher 1-2-3-... au lieu de 0-1-2-3-...
echo "<a href=\"Demandes_doc_test_pagination.php?page=".($i+1)."\"> Page ".($i+1)."</a> ";
}
//*********** Partie concernant le "bouton" suivant ***********\\
//on vérifie qu'il y a au minimum 2 page a afficher pour utiliser
//la fonction Suivant / précédent
if ($moy>=2)
{
//on vérifie l'éxistence de la variable page avant les vérifications
if (isset($_GET['page']))
{
//si $_GET['page'] = $moy alors on est a la dernière page et donc pas besoins
//de lien vers la suivante qui n'éxiste pas
if ($_GET['page']==$moy){echo " Suivant";}
//sinon on met le lien en ajoutant +1 page a la page courante
else
{
echo " <a href=\"Demandes_doc_test_pagination.php?page=".($_GET['page']+1)."\">Suivant</a>";
}
}
else{echo "<a href=\"Demandes_doc_test_pagination.php?page=1\">Suivant</a>";}
}
//*********** fin de la partie concernant le "bouton" Suivant ***********\\
echo "<br>La page courante est :".$_GET['page'];
?>
</table>
</form> |
Partager