Solved

Paging Using PHP

Posted on 2016-11-24
7
28 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 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
Comment Utility
thank you Ray Paseur
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

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

Expert Comment

by:Sachin Singh
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
thank you Sachin Singh and Julian Hansen,

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now