Jump to content
Killersites Forums

markjwrx

New Members
  • Posts

    1
  • Joined

  • Last visited

markjwrx's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello I am using the code below along with an XML file that contains all the data that the php below searches and suggests matching words and displays the text. I am able to adjust the font of the outputted text by applying a class to the table. This does not have any effect on the colour or decoration of the hyper link that is produced. I know need to add an <a class="links"> to the code some where and then apply a non decoration class but i just can't work out how to apply the html within the PHP. I guess its needs to be added to the echo parts at the bottom ? Many thanks in advance ! <?php $xmlDoc=new DOMDocument(); $xmlDoc->load("links.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 . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $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; ?>
×
×
  • Create New...