如何为HTML,PHP,Javascript,MySQL中的搜索结果创建“页面”

Let's assume for following structure:

A table with two columns: id, name.

Let's assume the table consists of thousands of rows.

I have a search engine that allows me to search by free text.

The query I use to retrieve the data is as following:

SELECT * FROM `table` WHERE `name` LIKE '%$search%'

Let us also assume that the entire results are saved as associative array in a variable name $results.

I want to display them in a CSS designed html table (This is important because it slows the browser data loading).

Now, I have 2 options here:

Load all the thousands of results into the same page at once, and use the "display" to change between "pages".

Or,

I could with ajax for example, make a different search for each number I click that changes a the "LIMIT TAB_NUMBER*NUM_OF_RESULTS_PER_PAGE, NUM_OF_RESULTS_PER_PAGE".

Anyone got better idea?

Use offset and limit in query and use pagination. you should not pull all the records because if you pull all records all data will come to page but will not display but you will display 20 or 30 records. so every time you get all records on page which is bad practise. you can use ajax also. that is good