ajax + php auto suggest field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

ajax + php auto suggest field

Post by hame22 »

Hi

I have set up a auto suggest facility on a text field using php/mysql and ajax, this is working fine.

What I was wondering is whether it is possible to cache results returned. I feel that for every keystroke to connect to database each time coulkd be inefficient.

I have not worked with caching before but does anyone have any experience or suggestions?

Thanks in advance
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Re: ajax + php auto suggest field

Post by ianhull »

I also have never worked with caching before but I would probably set a session with the results and store everything there, if the session isset then include the values in the list too.

If anyone else has any other suggestions I would also like to hear them :)
Li0rE
Forum Commoner
Posts: 41
Joined: Wed Jun 07, 2006 6:26 am

Re: ajax + php auto suggest field

Post by Li0rE »

yes, setting it in a session or cookie would be good (session if you have some server resources to blow or cookies if you want to screw your user :p), but if someone types in a and 1,000,000 results are going to be cached however, it would be more efficient to connect to db each time.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Re: ajax + php auto suggest field

Post by hame22 »

i am limiting the results to the nearest 10.

When was talking about caching I was thinking that it would not be user dependent. ie. person a carries out a search that sql is cached person b 5 minutes later performs the same search and gets the cached results rather than resubmitting the same query. There is a pear package cache lite that may help but have no experience with it, has anyone else used alternatives?
Post Reply