Hey,
I have a simple "live search" (results displayed while typing) web site. This make up is Ajax to PHP querying a pretty large XML document (10,000+ lines). This is all been hosted on a local Apache server (xamp). The scale of the xml document seems to be causing huge performance issue with results taking 10ish seconds to give the results.
I'm very new to PHP (this actually being my first play about) so there below is a snippet of code in case there is something obvious
for($i=0; $i<($foodListXML->length); $i++){
$type=$foodListXML->item($i)->getElementsByTagName('type');
$foodnote=$foodListXML->item($i)->getElementsByTagName('foodnote');
$style=$foodListXML->item($i)->getElementsByTagName('style');
if ($type->item(0)->nodeType==1)
{
//find a link matching the search text
if (stristr($type->item(0)->childNodes->item(0)->nodeValue,$q)){
$currentFoodName = $type->item(0)->childNodes->item(0)->nodeValue;
$currentFoodStyle = $style->item(0)->childNodes->item(0)->nodeValue;
$currentFoodNote = $foodnote->item(0)->childNodes->item(0)->nodeValue;
if ($hint==""){
$hint= $currentFoodName . " , " . $currentFoodNote . " , <b>" . $currentFoodStyle. "</b>" . "<br>" ;
}
else{
$hint=$hint . $currentFoodName . " , " . $currentFoodNote . " , <b>" . $currentFoodStyle. "</b>" . "<br>" ;
}
}
}
}
}
Also if having the data in a DB and accessing that is faster, then I'm open to that.. All ideas really!!
Thanks.