Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Paging Using PHP

Posted on 2016-11-24
7
Medium Priority
?
72 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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 59

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 59

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …
Suggested Courses

618 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