Solved

Paging Using PHP

Posted on 2016-11-24
7
54 Views
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;>
<tr>
  <td><span class=yazibaslik>İlan Başığı: $id </span></td>
</tr>
<tr>
  <td><span class=yazibaslik>Şehir: $sehir</span></td>
</tr>
<tr>
  <td><span class=yazibaslik>Kategori: $kategori </span></td>
</tr>

</table>";
}

Open in new window

1
Comment
Question by:Braveheartli
7 Comments
 
LVL 109

Accepted Solution

by:
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.
https://www.sitepoint.com/perfect-php-pagination/
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41900579
thank you Ray Paseur
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41901245
We also have an article here at EE that covers this topic
https://www.experts-exchange.com/articles/12238/Pagination-with-PHP-and-Mysql.html
1
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 1

Author Comment

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

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.

https://www.mindstick.com/blog/265/pagination-in-php

http://www.freezecoders.com/2014/01/simple-pagination-using-php-mysql.html

Thanks
1
 
LVL 54

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.
1
 
LVL 1

Author Comment

by:Braveheartli
ID: 41901450
thank you Sachin Singh and Julian Hansen,

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to dynamically set the form action using jQuery.

786 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