Jump to content

Recommended Posts

I have searched the web for days now.

 

does anyone know a working script for a live search.  (where you type in, and it starts to list items from an xml document that you can click on)

I just need one working one, so that i can learn how to make it, and what each item does.

 

I have not found one working code online.  Yet several examples.  w3schools is perfect, but their code doesnt work.

 

Please any help is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/
Share on other sites

I'm going to assume you have an intermediate understanding of various web technologies. I'm not sure of where to find a tutorial, but if you -are- indeed familiar with these technologies, just knowing the concept is enough. Here's the basic idea behind a live search (of course, this is probably unoptimized and inefficient for a larger user base).

 

You'd need a mixture of a server-side language, a client-side language, and a database. Such as PHP, Javascript and MySQL, respectively.

 

What you do is you use AJAX (javascript) to call an external PHP page that returns an XML listing from the database, and this should be attached to that search textfield's onchange or onblur event.

 

The PHP script will use a query that might look like this:

 

  SELECT * FROM searchData WHERE title LIKE "%$DATA%"    -- replacing $DATA of course

 

Then use Javascript to organize the returned result into an HTML table, and put that into a floated or absolutely positioned div on the page that hovers over the textfield.

yea iv got a good understanding of the procedure, i dont even have to use xml i can just search the database, but the problem i guess i encounter is how to do the live part.  how to make it start searching as you type.  like im not too great in javascript but is there some function that knows when you hit the keys?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.