Thanks Matt

I'm trying to build this PHP backend but nothing is working, again my skills
are not so good so if anyone could point me in the right direction ;)


Here is what I come with, expecting to extract the data from my db and then
sort them under a xml skeleton

<?php 
  define ("MYSQLHOST", "localhost");
  define ("MYSQLUSER", "xxx");
  define ("MYSQLPASS", "xxx");
  define ("MYSQLDB", "xxx");

 function opendatabase(){
    $db = mysql_connect (MYSQLHOST,MYSQLUSER,MYSQLPASS);
    try {
      if (!$db){
        $exceptionstring = "Error connecting to database: <br />";
        $exceptionstring .= mysql_errno() . ": " . mysql_error();
        throw new exception ($exceptionstring);
      } else {
        mysql_select_db (MYSQLDB,$db);
      }
       return $db;
     } catch (exception $e) {
       echo $e->getmessage();
       die();
     }
   }

 function search(){
   $query = "SELECT iso_alpha2, name, population, continent FROM countryinfo
ORDER BY name ASC";
        $database->setQuery( $query );
$name = $database->loadObjectList();
$iso = $_GET['iso_alpha2'];
$population = $_GET['population'];
$continent = $_GET['continent'];

header('Content-type: text/xml');

$q = strtolower($_GET["q"]);
if (!$q) return;
header('Content-type: text/xml');
$items = array(
echo "<?xml version="1.0"?>";
echo "<ajaxresponse>";
foreach ($options as $items) {
echo "  <item>";
echo "    <text><![CDATA[<strong>' .$iso. '</strong><br >' .$name.
']></text>";
echo "    <value><![CDATA[' .$iso. ']]></value>";
echo "    <district><![CDATA[' .$continent. ']]></district>";
echo "    <population><![CDATA[' .$population. ']]></population>";
echo " </item>";
}
echo "</ajaxresponse>";
);
$items = array_flip($items);
foreach ($items as $key=>$value) {
        if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
        }
}
}
-- 
View this message in context: 
http://www.nabble.com/jquery-autocomplete-and-mysql-tf2783514.html#a7873838
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to