Thanks Matt
I'm trying to build this PHP backend, 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
So now it's working but I have only one country (the first one). The foreach
function must be the problem, but I really can't figure why
<?php
header('Content-type: text/xml'); // output as XML
// $q = strtolower($_GET["q"]);
// if (!$q) return;
// connect to MySQL & load database
mysql_connect('localhost','xxx','xxx');
if ([EMAIL PROTECTED]('xxx')) { exit('<p>Unable to locate the ' .
$database . ' database at this time.</p>'); }
// retrieve customer data
$query="SELECT iso_alpha2, name, population, continent FROM
countryinfo ORDER BY iso_alpha2 DESC";
$result=mysql_query($query);
if (!$result) { exit('<p>Error performing query: ' . mysql_error() .
'</p>'); }
// close db
mysql_close();
while ($row = mysql_fetch_array($result)) {
$iso2 = $row['iso_alpha2'];
$name = $row['name'];
$population = $row['population'];
$continent = $row['continent'];
// etc. etc.
}
$rows = array('iso_alpha2');
foreach ($rows as $row) {
$returnData = " <item>";
$returnData.= " <text><![CDATA[<strong>$iso2</strong><br
>$name]]></text>";
$returnData.= " <value><![CDATA[$iso2]]></value>";
$returnData.= " <district><![CDATA[$continent]]></district>";
$returnData.= " <population><![CDATA[$population]]></population>";
$returnData.= " </item>";
}
$returnXML = "<?xml version=\"1.0\"?>";
$returnXML.= "<ajaxresponse>";
$returnXML.= "$returnData";
$returnXML.= "</ajaxresponse>";
echo $returnXML;
?>
--
View this message in context:
http://www.nabble.com/jquery-autocomplete-and-mysql-tf2783514.html#a7876110
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/