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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dr_dedoCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
v2MediaCommented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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
ChorchCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.