optikalefx Posted August 12, 2007 Share Posted August 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/ Share on other sites More sharing options...
ILYAS415 Posted August 12, 2007 Share Posted August 12, 2007 Why not just use a mysql database? Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/#findComment-321519 Share on other sites More sharing options...
Guest Posted August 12, 2007 Share Posted August 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/#findComment-321539 Share on other sites More sharing options...
optikalefx Posted August 12, 2007 Author Share Posted August 12, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/#findComment-321929 Share on other sites More sharing options...
optikalefx Posted August 12, 2007 Author Share Posted August 12, 2007 oh onChange, got it Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/#findComment-321931 Share on other sites More sharing options...
hostfreak Posted August 12, 2007 Share Posted August 12, 2007 For this specific application I prefer onKeyUp Quote Link to comment https://forums.phpfreaks.com/topic/64482-ajax-live-search-overload/#findComment-321937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.