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
|
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document sans nom</title>
</head>
<body>
<?php
include('config.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["activite"])) {
$activiteErr = "activite is required";
} else {
$activite = test_input($_POST["activite"]);
// check if activite only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$activite)) {
$activiteErr = "Only letters and white space allowed";
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div class="bloc_recherche_adresse">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<table width="200" border="1">
<tr>
<td>Nom/activité: <input type="text" name="activite" value="<?php echo $activite?>">
</td>
<td>Ville: <input type="text" name="ville"></td>
<td><input type="submit" class="btnrecherhce" name="submit" value="Submit"></td>
</tr>
</table>
</form>
</div>
<div class="bloc_resultat">
<?php
$activite=test_input($_POST["activite"]);
$max = 9;
$select = "SELECT * FROM t_adresse WHERE designation = '$activite'";
$query1 = mysql_query($select) or die( mysql_error() );
$total = mysql_num_rows($query1);
$nav = new Pagination($max, $total, $_GET['p']);
$nav->url = 'index1.php?p=';
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
while($item = mysql_fetch_object($query2))
{
echo $item->id . ' - <b>' . $item->name . '</b><br />';
}
echo $nav->get_html();
?>
</div>
</body>
</html> |
Partager