2009-02-17 13:14:53 +00:00
|
|
|
|
<?php
|
|
|
|
|
$q = (!$_GET["q"])? "" : strtolower($_GET["q"]);
|
|
|
|
|
if (!$q) return;
|
|
|
|
|
require_once( realpath(dirname(__FILE__).'/../../config/config.inc'));
|
|
|
|
|
//Connection mysql
|
|
|
|
|
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die("Impossible de se connecter : " . mysql_error());
|
2009-02-23 16:14:03 +00:00
|
|
|
|
mysql_query("SET NAMES 'utf8'");
|
2009-02-17 13:14:53 +00:00
|
|
|
|
$db_selected = mysql_select_db(MYSQL_DB, $link);
|
|
|
|
|
if (!$db_selected) { die ('Impossible de s<>lectionner la base de donn<6E>es : ' . mysql_error()); }
|
|
|
|
|
//Lecture des donn<6E>es mysql
|
|
|
|
|
$sql = "SELECT codNaf5, libNaf5 FROM tabnaf5 WHERE codNaf5 LIKE '%$q%' OR libNaf5 LIKE '%$q%' ORDER BY poids DESC";
|
|
|
|
|
$result = mysql_query($sql);
|
|
|
|
|
if ( mysql_num_rows($result)>0 && mysql_num_rows($result)!=FALSE ){
|
|
|
|
|
while ($row = mysql_fetch_assoc($result)) { $items[$row['codNaf5']] = "".$row['libNaf5'].""; }
|
|
|
|
|
//Envoi des informations
|
|
|
|
|
$separator = " , "; //Le separateur doit <20>tre le m<>me que celui pr<70>sent dans le code javascript
|
|
|
|
|
foreach ($items as $key=>$value) {
|
|
|
|
|
if (strpos(strtolower($key), $q) !== false || strpos(strtolower($value), $q) !== false ) {
|
|
|
|
|
echo $key . $separator . $value. "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|