Jump to content

Linking database search to markers on Google Map


robbb99

Recommended Posts

Hi there,

 

I have a auto-complete search function on my site and i would like the results to link to the corresponding room markers on the page. (Please take a look http://robmaps.co.uk/Floor_plans/Chadwick/firstfloor.html). At the moment they just link to a new page, but somehow i need to get the PHP to covert the nodeValue to a gmarkers[] index.

 

The current PHP is below, where the 'Title' is the name of the person that comes up when typed into the search box, and 'URL' is the room number that shoud correspond with the room markers.

 

<?php

$xmlDoc = new DOMDocument();
$xmlDoc->load("links2.xml");
$x=$xmlDoc->getElementsByTagName('link');

//get the q parameter from URL
$q=$_GET["q"];

//lookup all links from the xml file if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<($x->length); $i++)
{
$y=$x->item($i)->getElementsByTagName('title');
$z=$x->item($i)->getElementsByTagName('url');
if ($y->item(0)->nodeType==1)
  {
  //find a link matching the search text
  if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))
   {
   if ($hint=="")
    {	
    $hint="<a href='" . 
    $z->item(0)->childNodes->item(0)->nodeValue . 
    "'>" . 
    $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
    }
   else
    {
    $hint=$hint . "<br /><a href='" . 
    $z->item(0)->childNodes->item(0)->nodeValue . 
    "'>" . 
    $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
    }
   }
  }
}
}

// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}
//output the response
echo $response;
?>

 

Does anyone have any suggestions?

Thanks for looking.

 

Rob

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.