+ 1

How to paginate in PHP?

I have a form or a Search Engine rather, and I want to paginate the results say like 5 results per page (table being 'users') - (search_engine.php) <form method = "GET" action="pagination.php"> <input type ="text" name= "keyword"> <button type="submit" name="search"> SEARCH </button> </form> And what I want is the code to be written on "pagination.php". Pliz help me out. THANK YOU.

25th Jan 2018, 6:46 PM
Pukhramabam Prameshwormani Singh
2 Antworten
0
In sql query you can specify your starting index and how many rows you want. select * from users where name=$keyword LIMIT 0, 5 next page would be LIMIT 5, 5 The first number is the starting index and the second one is how many rows starting from the index you want. Increase the first number by 5 per every page
25th Jan 2018, 7:40 PM
Toni Isotalo
Toni Isotalo - avatar
0
Works fine for once but when I click page 2 I get "undefined index $keyword error.
26th Jan 2018, 1:14 AM
Pukhramabam Prameshwormani Singh