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
| <?php
include('connexion.inc');
?>
<html>
<head>
<title>Info-commune</title>
</head>
<body>
<form method="post" action="index.php">
<fieldset> <legend>Choississez vos critères </legend>
<label>Commune</label> <input type="text" id="nom" name="nom" style="width:150px;" />
<label>Departement</label> <input type="text" id="dept" name="dept" style="width:150px;" />
<label>Population</label> <input type="text" id="pop" name="pop" style="width:150px;" />
<label>Region</label> <input type="text" id="reg" name="reg" style="width:150px;" />
<input type='submit' value='Valider'>
</fieldset>
</form>
<?php
if (isset($_POST['nom'])) {
$cherchnom = $_POST['nom'];
} else {
$cherchnom = '';
}
if (isset($_POST['population'])) {
$cherchpop = $_POST['population'];
} else {
$cherchpop = '';
}
if (isset($_POST['departement'])) {
$cherchdep = $_POST['departement'];
} else {
$cherchdep = '';
}
if (isset($_POST['region'])) {
$cherchreg = $_POST['region'];
} else {
$cherchreg = '';
}
$messagesParPage=15;
$retour_total = "SELECT COUNT(*) AS total FROM communes Where nom like '$cherchnom%'or dept='$cherchdep' or region = '$cherchreg'";
$donnees_total = $connexion->prepare($retour_total);
$donnees_total->execute();
$result = $donnees_total->fetchAll(PDO::FETCH_ASSOC);
$total=$result[0]['total'];
$nombreDePages=ceil($total/$messagesParPage);
if(isset($_GET['page']))
{
$pageActuelle=intval($_GET['page']);
if($pageActuelle>$nombreDePages)
{
$pageActuelle=$nombreDePages;
}
}
else
{
$pageActuelle=1;
}
$premiereEntree=($pageActuelle-1)*$messagesParPage;
$req = $connexion->prepare("SELECT * FROM communes Where nom like '$cherchnom%'or dept='$cherchdep' or region = '$cherchreg' LIMIT '.$premiereEntree.', '.$messagesParPage.' ");
$req->execute();
$req->setFetchMode(PDO::FETCH_ASSOC);
$Idd = 1;
while ($affichage = $req->fetchObject()) {
?>
<table>
<thead>
<tr>
<td><font size="2" ><b>N°</b></font></td>
<td><font size="2" ><b>Nom</b></font></td>
<td><font size="2" ><b>Population</b></font></td>
<td><font size="2" ><b>Departement</b></font></td>
<td><font size="2" ><b>N° commune</b></font></td>
<td><font size="2" ><b>Région</b></font></td>
</tr>
</thead>
<tr>
<td><?php echo $Idd ?></td>
<td><?php echo '<a href="recherche.php?nom_ascii_maj='.$affichage->nom_ascii_maj.'®ion='.$affichage->region.'&population='.$affichage->population.'&departement='.$affichage->dept ?>"><?php echo $affichage->nom_ascii_maj ?></a></td>
<td><?php echo $affichage->population ?></td>
<td><?php echo $affichage->dept ?></td>
<td><?php echo $affichage->comm ?></td>
<td><?php echo $affichage->region ?></td>
</tr>
<?php
$Idd = $Idd + 1;
}
?>
</table>
<?php
echo '<p align="center">Page : ';
for($i=1; $i<=$nombreDePages; $i++)
{
if($i==$pageActuelle)
{
echo ' [ '.$i.' ] ';
}
else
{
echo ' <a href="index.php?page='.$i.'">'.$i.'</a> ';
}
}
echo '</p>';
?>
</body>
</html> |