I'm workin a ajax search box (my first module for 4.6.8 for the community) with a visible/hidden field with keywords. With a static array, it's work perfect, but when I try to make the same with a recordset I receive a error.

I wish convert my variable "$keywords" into a array like this:
$liste = array("abeille","abricot","acheter","acheteur","zèbre","zéro");
I try to do so:
$liste = $keywords;
But I receive a error:
Warning : Invalid argument supplied for foreach() in c:\documents and settings\web1\my documents\www\ajax\autocomplete\options.php on line 21.
Line 21 are:
foreach ($liste as $element) {
What is wrong?
A lot of thx for your help and time.
Regards,
Dominique
My php code:
Code: Alles auswählen
<?php include '../Connections/connect.php';
mysql_select_db($database_connect, $connect);
$keywords = "SELECT artist_name FROM artists";
header('Content-Type: text/xml;charset=utf-8');
echo(utf8_encode("<?xml version='1.0' encoding='UTF-8' ?><options>"));
if (isset($_GET['debut'])) {
$debut = utf8_decode($_GET['debut']);
} else {
$debut = "";
}
$debut = strtolower($debut);
//$liste = $keywords;
$liste = array("abeille","abricot","acheter","voisin","voisinage","vouloir","voyage","voyageur","zèbre","zéro");
function generateOptions($debut,$liste) {
$MAX_RETURN = 10;
$i = 0;
foreach ($liste as $element) {
if ($i<$MAX_RETURN && substr($element, 0, strlen($debut))==$debut) {
echo(utf8_encode("<option>".$element."</option>"));
$i++;
}
}
}
generateOptions($debut,$liste);
echo("</options>");
?>