Hi,
I have a problem to add more than one data to my xml result.
Here my php :CODE
<?php
// begin XML output
$xmlStr = <<<XML
<?xml version='1.0' standalone='yes'?>
<xmlresult>
XML;
// open database connection
$mysqli = new mysqli("localhost", "root", "", "test");
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
// retrieve result list matching input
// add to XML document
$q = $mysqli->real_escape_string($_GET['query']);
$sql = "SELECT notes, id FROM bm_service WHERE notes LIKE '%" . $q . "%' ORDER by notes";
if ($result = $mysqli->query($sql)) {
while ($row = $result->fetch_row()) {
$xmlStr .= '<result notes="' . $row[0] . '"></result>';
[color="#FF0000"]Here i want to add also id="' . $row[1] . '"[/color]
}
$result->close();
}
// clean up
// output XML document
$mysqli->close();
$xmlStr .= '</xmlresult>';
header("Content-Type: text/xml");
echo $xmlStr;
?>
And i receive the xml here :
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="/yui/build/autocomplete/assets/skins/sam/autocomplete.css" />
<script type="text/javascript" src="/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="/yui/build/connection/connection-min.js"></script>
<script type="text/javascript" src="/yui/build/animation/animation-min.js"></script>
<script type="text/javascript" src="/yui/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="/yui/build/autocomplete/autocomplete-min.js"></script>
</head>
<body class="yui-skin-sam">
<h3>Add Title</h3>
<form action="" method="post">
Recherche:<br/>
<div style="width:200px">
<input id="Result[notes][0]" type="text" name="Result[notes][0]"/>
<div id="ac0"></div>
</div>
<p/><br/><p/>
<input type="submit" name="submit" value="Save" />
</form>
<script type="text/javascript">
YAHOO.example.autocomplete = function() {
var oConfigs = {
prehighlightClassName: "yui-ac-prehighlight",
queryDelay: 0,
minQueryLength: 0,
animVert: .01,
}
// instantiate remote data source
// code based on example at
// http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_xhr.html
var oDS = new YAHOO.util.XHRDataSource("get_data.php");
oDS.responseType = YAHOO.util.XHRDataSource.TYPE_XML;
oDS.responseSchema = {
resultNode: 'result',
fields: ['notes'] [color="#FF0000"]Add i field here ??? [/color]
};
oDS.maxCacheEntries = 20;
// instantiate YUI autocomplete widgets
var oAC0 = new YAHOO.widget.AutoComplete("Result[notes][0]", "ac0", oDS, oConfigs);
return {
oDS: oDS,
oAC0: oAC0
};
}();
</script>
</body>
</html>
My question is : how can i use the id field, like the notes field ?
Thanks a lot