views:

39

answers:

2

Hi Guys

I am just learning php and ended up at this tutorial http://www.w3schools.com/php/php_ajax_livesearch.asp

Till now my PHP search file looks the same as in example but i changed the if (strlen($q) > 0) to if (strlen($q) > 3) to display results after typing minimum 3 words. I am wondering how can i make the results paginate if there are lots of them?

Thanks

Roshan

+1  A: 

You would need to page after obtaining the number of records from your database. Paging should be done by the same script that echos your ajax response.

Here is how to page: PHP MySQL paging.

Babiker
ok thanks...i will look into that :)
Roshan
+1  A: 

The idea of search suggestions is to show the user what do you have in your site, in terms of relevance, that match his query. This being said, you should only throw a subset of results, being the first result the most relevant, instead of the whole file or database. In others words, you don't need pagination.

Show the user 5 or 10 items, if he doesn't find what he's after he'll keep writing until he finds it. If he doesn't finds it he will just search it. Remember that it is a suggestion and nothing more.

Ben
yeah good idea but how would i implement this into my php code...to just give a particular set of results as you say?
Roshan