Home>

There is a code on a lively search (download code from the Internet) Everything works, but you need to upgrade it and learn to configure, help! I am a kettle, the code for now perceive only visually, it is still difficult to add something, especially when not everything is clear, but I will learn :)

Question:

How to convert a search on a CSV file?

Thank you to your answer!

Live Search.php code


≪
? php.
$ xmldoc= new domdocument ();
$ xmldoc->
Load ("convertcsv.xml");
$ x= $ xmldoc->
GetElementsBytagname ('Row');
//Get The Q Parameter From URL
$ Q= $ _ Get ["Q"];
//Lookup All Links from the XML File If Length of Q >
0.
if (strlen ($ q) >
one)
{
$ hint= "";
For ($ i= 0; $ i <
($ x->
Length); $ i ++)
  {
  $ y= $ x->
Item ($ i) ->
GetElementsByTagname ('user_id');
  $ z= $ x->
Item ($ i) ->
GetElementsByTagname ('user_id');
  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;
? ≫

code index.html

<
HTML >
≪
HEAD >
≪
script >
Function ShowResult (STR)
{
if (str.length== 0)
  {
  Document.getelementByid ("LiveSearch"). Innerhtml= "";
  Document.getelementByid ("LiveSearch"). style.border= "0px";
  Return;
  }
if (window.xmlhttprequest)
  {//Code for IE7 +, Firefox, Chrome, Opera, Safari
  xmlhttp= new xmlhttprequest ();
  }
ELSE.
  {//Code for IE6, IE5
  xmlhttp= new activexobject ("microsoft.xmlhttp");
  }
xmlhttp.ONReadyStateChange= FUNCTION ()
  {
  if (xmlhttp.readystate== 4 &
&
 xmlhttp.status== 200)
    {
    Document.getelementByid ("LiveSearch"). Innerhtml= xmlhttp.ResponseText;
    Document.getelementByid ("LiveSearch"). style.border= "1px Solid # A5ACB2";
    }
  }
xmlhttp.open ("get", "livesearch.php? q="+ str, true);
xmlhttp.send ();
}
≪
/script >
≪
/Head >
≪
Body >
≪
Form >
≪
INPUT TYPE= "TEXT" SIZE= "30" ONKEYUP= "SHOWRESULT (THIS.VALUE)" >
≪
DIV ID= "LiveSearch" >
≪
/div >
≪
/Form >
≪
/Body >
≪
/HTML >

You are a novice developer in 2021 in general at all what is IE5, IE6 to include this in the code? When you look for code on the Internet, you take at least the search criteria over the past 5 years, and not 20.

teran2021-07-17 03:37:07

Yes, I saw, I decided not to touch, everything is as it is.

Vlad2021-07-16 10:24:18

It can be removed without problems :)

Vlad2021-07-16 10:24:43