PHP paging

Hello, i'm doing PHP paging, to split results from mysql database into some pages.
I googled and i found how to make paging like that:
index.php?page=1, index.php?page=2 and so on
but what i want is to make like this:
index-1.php, index-2.php and so on. As soon as in db more data, it creates index-3.php and so on... How to make that? HELP :)
usssarAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dr_dedoConnect With a Mentor Commented:
this is basicaly Wrong, you shouldn't do that at all, this way, you dont use the very good and the purpose of php which is dynamic web pages
anyway, you could convert index.php?page=1 to anything you like, just create a new script that does this (if you know how many pages are there)

for ($i=1;$i<$page+1;$i++){
$data = file_read_contents ("index.php?page=$page");
files_put_contents ("index-$page.php",$data);
}
 
that's the easiest way to do it

Open in new window

0
 
v2MediaConnect With a Mentor Commented:
Wrong indeed! Are you concerned about SE friendly url's or something? SE's will index your site just as easily with ?page=1. This approach isn't very scalable either. What if your page gets busy with 220 pages of results to get through? Adding a file dump after a round trip to mysql is a lot of overhead for just changing the page url.
0
 
AlexSoftware EngineerCommented:
0
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.

 
Loganathan NatarajanLAMP DeveloperCommented:
but what i want is to make like this:
index-1.php, index-2.php and so on. As soon as in db more data, it creates index-3.php and so on... How to make that? HELP :)

>> are you trying to hide the query string values OR need to create files for more data ...?

As ***dr_dedo*** said, you can create files ... but is not good practice to create as many as for all the DB records...

actually what are you trying to archive out of this.??

Want hide something to the user or ??
0
 
ChorchConnect With a Mentor Commented:
I use a .htaccess file with these contents.

I dinamically create the links as you do with php (index-1.html, index-2.html, etc) from database, but build the query with a rewrite rule:

RewriteEngine on
Options FollowSymlinks
RewriteBase /
 
RewriteRule index-(.*).html /index.php?page=$1

Open in new window

0
All Courses

From novice to tech pro — start learning today.