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
| <?php
session_start ();
if (isset($_SESSION['login']) && isset($_SESSION['pass'])) {
include('../includes/connectionbdd.php');
$sql = "SELECT * FROM `ficheform` ORDER BY `raisonsociale` ASC";
mysql_select_db($dbname, $conn);
$result = mysql_query($sql);
$str = strtoupper($_POST['str']);
$Json = '{"suggest": [';
$stock = array();
while ($item = mysql_fetch_array ($result)) {
$str_titre = substr(strtoupper($item['raisonsociale']),0,strlen($str));
if ($str_titre == $str){
$titre = htmlentities($item['raisonsociale']);
$rubrique = htmlentities($item['numfiche']);
$objet = '{"raisonsociale":"'.$titre.'","numfiche":"'.$rubrique.'"}';
array_push($stock,$objet);
}
}
$Json .= implode(",",$stock);
$Json .= ']}';
echo $Json;
}
else
{
header('Location: login.php');
}
?> |
Partager