Paging Using PHP

Posted on 2016-11-24
1 Endorsement
Last Modified: 2016-11-25
Dear experts, I use below code to print out every row in table.
But there are many rows that can not fit in a page.

what I want to do is to list every 100 row in the first page and give "next 100" link for the other 100 so on...
I see it on blog pages.

I want to show query result in multiple pages instead of just put them all in one long page.

How can I do this with php?

My code is:

$sql9 = "SELECT * FROM xxxxxxx";
$result9 = $conn->query($sql9);

      while($row9 = $result9->fetch_assoc()) {
	$id= $row9["id"];
	$kategori= $row9["kategori"];
	$sehir= $row9["sehir"];

echo "<table class=ab width=990px; style=max-width=990px;>
  <td><span class=yazibaslik>İlan Başığı: $id </span></td>
  <td><span class=yazibaslik>Şehir: $sehir</span></td>
  <td><span class=yazibaslik>Kategori: $kategori </span></td>


Open in new window

Question by:Braveheartli
LVL 109

Accepted Solution

Ray Paseur earned 500 total points
ID: 41900576
The canonical article on "pagination" is from Sitepoint.  It's old, but it has stood the test of time.

Author Closing Comment

ID: 41900579
thank you Ray Paseur
LVL 55

Expert Comment

by:Julian Hansen
ID: 41901245
We also have an article here at EE that covers this topic
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 41901247
Thank you Julian. I saw it yesterday after the question. It's perfect. Thank you

Expert Comment

by:Sachin Singh
ID: 41901434
Paging means showing your query result in multiple pages instead of just put them all in one long page.Check this helpful link i hope it will help you.

LVL 55

Expert Comment

by:Julian Hansen
ID: 41901446
Please note the links posted above both refer to samples that make use of the deprecated MySQL library. You should not consider using any code that is still dependent on this library. If you do decide to use the code you should convert it to use MySQLi.

Author Comment

ID: 41901450
thank you Sachin Singh and Julian Hansen,

I will use MySqli, thank you for reminding me this.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question