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
|
<?php
//prolongation session
session_start() ;
//importation config.php
require('./require/config.php');
/*requête pour rechercher les operations dans une commune*/
$sql = "select p.surface, p.annee_terrain, p.ro, p.code_tranche, p.nomope, c.nom_com from activite.prescription p, activite.communes c
where st_intersects(p.geom, c.geom) and nom_com ilike $1 order by p.annee_terrain DESC, p.ro, p.nomope" ;
$marequete = pg_query_params(pg_connect("host=$serveur port=$port dbname=$base user=$_SESSION[identifiant] password=$_SESSION[mot_de_passe]"
), $sql, array($_POST[nom_com] )) ;
/*requête pour savoir si la commune existe*/
$sql2= "select nom_com from activite.communes where nom_com ilike $1" ;
$verifcom = pg_query_params(pg_connect("host=$serveur port=$port dbname=$base user=$_SESSION[identifiant] password=$_SESSION[mot_de_passe]"
), $sql2, array($_POST[nom_com] )) ;
?>
<html>
<head>
<title>Recherche par commune</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href=".\styles_md.css" media="screen" />
</head>
<body class="iimagemenu">
<div class="">
<form action="opecomm.php" method="POST" >
<h4>Recherche des opérations par commune</h4>
<h5 class = "alert alert-warning">Saisir le nom de la commune</h5>
<p class="psga" >nom commune : <input type="text" name="nom_com" class = "alert alert-info">
<input type="submit" class = "alert alert-info" name="submit" value="rechercher"></p>
</form>
</div>
<?php
//test si la commune existe...
if (isset($_POST['submit']))
if (pg_fetch_array($verifcom) == 0)
{
echo "<h4 float= 'left' >la commune n'existe pas</h4>" ;
exit ;
}
//si la commune existe...
ELSE
{ //si pas de résultat...
//if (empty($marequete)) {
if (pg_fetch_array($marequete) == 0) {
echo "<h4 float= 'left' >Pas d'opération dans la commune de $_POST[nom_com] </h4>" ;
exit ;
}
ELSE
//sinon les opérations sur la commune
echo "<div name='tableau1' >
<table name='tableau_nbfaitop' class='doc' >
<thead>
<tr>
<th>surface</th>
<th>année d'intervention</th>
<th>responsable d'opération</th>
<th>code tranche</th>
<th>nom de l'opération</th>
<th>commune</th>
</tr>
</thead>" ;
while ($ligne = pg_fetch_array($marequete)){
echo "
<tbody>
<tr>
<td>$ligne[surface]</td>
<td>$ligne[annee_terrain]</td>
<td>$ligne[ro]</td>
<td>$ligne[code_tranche]</td>
<td>$ligne[nomope]</td>
<td>$ligne[nom_com]</td>
</tr>
</tbody>" ;
} /*boucle sur les lignes uniquement (body) pas sur tout le tableau (table)*/
"</table>
</div>" ;
}
?>
</body>
</html> |
Partager