Link to home
Start Free TrialLog in
Avatar of BR
BRFlag for Türkiye

asked on

Paging Using PHP

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

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BR

ASKER

thank you Ray Paseur
Avatar of Julian Hansen
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
Avatar of BR

ASKER

Thank you Julian. I saw it yesterday after the question. It's perfect. Thank you
Avatar of Sachin Singh
Sachin Singh

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
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.
Avatar of BR

ASKER

thank you Sachin Singh and Julian Hansen,

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