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
| <style >
ul.pagination {
text-align: center;
}
ul.pagination li {
display: inline;
margin: 10px 5px;
padding: 5px;
text-align: center;
}
ul.pagination li.page-courante {
font-weight: bold;
}
</style>
<?php // Paramètres de connexion
define('MYSQL_HOTE', 'localhost');
define('MYSQL_UTIL', 'julp');
define('MYSQL_MDP', 'motdepasse');
define('MYSQL_BDD', 'developpez');
// Paramètres de la pagination
// Nombre d'éléments à afficher sur une page
define('NB_PAR_PAGE', 9);
// Le modèle de la requête : ne modifiez que les champs à sélectionner et le nom
// de la table, gardez impérativement la clause LIMIT et la fonction SQL_CALC_FOUND_ROWS
define('MODELE_REQUETE', 'SELECT SQL_CALC_FOUND_ROWS * FROM logiciel LIMIT %d,%d');
$connexion=mysql_connect('localhost','root','') or die ("connexion impossible ");
$db=mysql_select_db('ruspina',$connexion) or die ("base de données non accessible");
$page = isset($_GET['pg']) ? max(intval($_GET['pg']), 1) : 1;
$debut = NB_PAR_PAGE * ($page - 1);
$res_r = mysql_query(sprintf(MODELE_REQUETE, $debut, NB_PAR_PAGE)) or die(mysql_error());
$res_n = mysql_query('SELECT FOUND_ROWS()') or die(mysql_error());
$NumRows = mysql_result($res_n, 0, 0);
$derniere_page = ceil($NumRows / NB_PAR_PAGE);
$req="select * from produit where type='logiciel' and genre='bureautique'";
$res=mysql_query($req);
$nb=mysql_num_rows($res);
$NbrLigne = 0;
if($nb>0)
{
$j = 1;
?>
<?php
for($i=0;$i<$nb;$i++)
{
$tab=mysql_fetch_row($res);
$id=$tab['0'];
$req1="select * from logiciel where id_logiciel='$id'";
$res1=mysql_query($req1);
$tab1=mysql_fetch_row($res1);
$NbrCol =3;
if ($j%$NbrCol == 1)
{
$NbrLigne++;
?>
<table width="238" border="0">
<tr>
<?php
$fintr = 0;
}
?>
<td width="200" height="324"><table width="100%" border="1">
<tr>
<td width="54%" height="188" valign="top"><div align="left">
<p align="center"><em><strong><?php echo $tab['2'];?></strong></em></p>
<p><img src="imgfilm/<?php echo $tab['4'];?>" width="190" height="105" /></p>
</div></td>
</tr>
</table></td>
<?php
if ($j%$NbrCol == 0)
{
?>
</tr>
<?php
$fintr = 1;
}
$j++;
}
?>
</table>
<?php
if ($NumRows > NB_PAR_PAGE) {
echo '<ul class="pagination">';
if ($page > 1) {
echo '<li><a href="' . basename(__FILE__) . '?pg=' . ($page - 1) . '">Page précédente</a></li>';
}
for ($i = 1; $i <= $derniere_page; $i++) {
if ($i == $page) {
echo '<li class="page-courante">' . $i . '</li>';
} else {
echo '<li><a href="' . basename(__FILE__) . '?pg=' . $i . '">' . $i . '</a></li>';
}
}
if ($page < $derniere_page) {
echo '<li><a href="' . basename(__FILE__) . '?pg=' . ($page + 1) . '">Page suivante</a></li>';
}
echo '</ul>';
}}
mysql_close();
?> |
Partager