0

How to do pagination in PHP in a search result?

Hello Everyone! I'm a PHP beginner so I'm a bit confuse. Someone pliz I mean plizzzzzzzzz explain how to paginate the results from my search engine in PHP. I'm dying my brain is going to blast. I don't want only the code but also the explanation. If there is someone willing to help me pliz do becoz I mean it. Thank you.

24th Jan 2018, 8:25 AM
Pukhramabam Prameshwormani Singh
6 ответов
+ 2
@Vincent okey I'll try everytime I click the pagination link like page 2 it didn't saw anything. Work fine once. $sql = "Select * from users WHERE name LIKE '% ".mysqli_real_escape_string($_GET['keyword"])."%' LIMIT start_limit,end_limit";
24th Jan 2018, 1:22 PM
Pukhramabam Prameshwormani Singh
+ 1
@Vincent thanks Bro! I did it now. what a fool am I.haha
26th Jan 2018, 4:37 AM
Pukhramabam Prameshwormani Singh
0
it's pretty simple. - make a variable that tells wich page you're on : $page = $_GET['page'] - add the LIMIT instruction to your SQL query : $sql .= 'LIMIT ' . $page* $x, $x $x is the number of result par page Then you print links to access each page ; get count of all your articles and divide it by $x. it's a simple problem, you really should try to solve it yourself before getting all made code
24th Jan 2018, 9:05 AM
Vincent
Vincent - avatar
0
@Vincent I want to submit the keyword from a search engine. You know what I mean?
24th Jan 2018, 12:43 PM
Pukhramabam Prameshwormani Singh
0
yes. i assumed you are not starting from scratch and at least can list your content, whatever it is, am i right ?
24th Jan 2018, 1:07 PM
Vincent
Vincent - avatar
0
your loop for print links should be something like this : $nbUsers = 125; $usersPerPage = 7; $page = 0; $nbPages = ceil($nbUsers / $usersPerPage); do{ echo "link.php?page=" . $page++; } while ($page < $nbPages); please mind that i couldn't test this code, it should gave you an idea of what to do.
24th Jan 2018, 3:40 PM
Vincent
Vincent - avatar