0

It's like to filter in real time. Each time the user insert a character in the input box, it checks in the database and returns if there is a value close to what the user inserted, then it makes a list with all close values returned from db.

Is it possible using Javascript? I think it will become too slow and I need the best performance, the app need to stay fastest as possible. I already tried using ajax (using Javascript/PHP) but that is not a good idea, tooo slow... I was thinking about node.js, what do you think? Any ideas?

I need to combine two input boxes too, to get close results from different columns in db.

Sorry about my english.

Thyoity
  • 191
  • 1
  • 4
  • 14
  • 1
    If the data is not huge (millions of data), you can get the complete list one time and filter at the client side using javascript. This way you can get the best performance. ( You can use filter method of the array to filter your selection ) – Shaik Mahaboob Basha Feb 21 '14 at 11:44
  • If you've ruled out AJAX then you're going to be stuck. – Andy Feb 21 '14 at 11:45
  • @ShaikMahaboobBasha that is a nice idea, but my database have millions of data (not kidding). – Thyoity Feb 21 '14 at 12:15
  • If you observe google, they implement their autocomplete using AJAX only, so AJAX is not so bad, you have to fine tune your application like google did. – Shaik Mahaboob Basha Feb 21 '14 at 12:18
  • @ShaikMahaboobBasha Yeah, I just read about: http://stackoverflow.com/questions/3670831/how-does-google-instant-work Thanks! I think I'll try to do with ajax. I would mark your answer as the accepted answer, but it's not possible because you posted as a comment, not as a answer. '-' – Thyoity Feb 21 '14 at 12:29
  • Hey thanks, but I answered with the SO question details. – Shaik Mahaboob Basha Feb 21 '14 at 12:37

3 Answers3

0

There are a lot of examples out there, i recommend you to read the following article, that discusses the differences between AJAX/jQuery for an implementation in PHP with an MySQL database. If you already implemented a solution but with performance issues, then post your code. Maybe there is some room for optimization.

Example PHP/jQuery/Ajax by IBM

alex
  • 5,516
  • 2
  • 36
  • 60
  • Hmmm... That is a nice article and I have read everything. But it don't say about performance. I think it'll become too slow if used with a database with millions of data. What do you think? – Thyoity Feb 21 '14 at 12:10
0

You can use JQuery autocomplete that it's a very powerfull tool.

There you have and example, you can see the code too:

http://jqueryui.com/autocomplete/

Xdevelop
  • 206
  • 2
  • 7
  • Autocomplete is not a good choice here. My database have too much data, and if I use autocomplete, the list will become toooo long. – Thyoity Feb 21 '14 at 12:03
0

You can try to use the idea from Google

Check this Already answered Stack over flow Question:

how google autocomplete works

Community
  • 1
  • 1