-3

How can i create pages in php, but don't create physical pages. The page don't exist in disk. I don't want create a physical page in disk for each page ... Image with 3 thousand pages ...

3 Answers3

0

Well, that's really general question. I assume that you're a beginner. Sorry if you're not but that what it seems to me like.

There are like 100 ways of creating website using PHP. PHP is there so you don't have to, like you said, create separate file for each page. If you did, it would be just a simple templating (you create HTML layout and put little PHP scripts inside so you can generate content dynamically).

I believe this isn't right place to ask. Instead you should look up some tutorials, get the picture of how PHP works in general and than maybe try something out and THAN ask again.

W3Schools.com is a great website to start with. Great tutorials, learned a lot there :-)

Michal Artazov
  • 4,368
  • 8
  • 25
  • 38
0

I think you want to avoid creating physical files on the disk.

The simplest thing comes in my mind, as you can use $_GET.

Take a look at this code.

index.php :

<?php
// Get the "page" information from HTTP GET.
$page = (isset($_GET["page"]) ? $_GET["page"]; : "default";

// Display content according to the page information from GET.
switch($page) {
 case "foo_page":
   echo "this is foo page.";
   break;
 case "bar_page":
   echo "this is bar page.";
   break;
 default:
   echo "this is the default page.";
   break;
}
?>

Now your index.php will respond

this is the default page.

But when you go to index.php?page=foo_page, you'll see that it outputs

this is foo page.

Then you could rewrite it by a .htaccess file.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_]+)/?$ index.php?page=$1 [NC,L]

Which would make your url's cleaner, like :

domain.com/foo_page/

domain.com/bar_page/

As i've told, this is the first thing i thought of when i read the question. Hope this helps, or at least gives an idea.

Community
  • 1
  • 1
mehmetseckin
  • 3,061
  • 1
  • 31
  • 43
0

I think you have lot's of images to display in page by page. Like page1|page2|etccc if so First you should plan how it works. In this case , ill do initialize a variable noofimage=30 another variable start-from=startfrom * finish.

initially start-from=0; // because it start from 0 to noofimage you specified to show in single page.Place this line below nofimage; do query in php to start from "start-from" to "noofimage" get total images and divide it by noofimage. if you have 3000 images then 3000/30=100 so now you have 100 pages. now using while loop create a page link

int i=1 // start from page 1
while(page<=100)
{
<a href="yoursite.com/images.php?pageno=$i>
i++ // increment page
}

now in your sitebelow page1|page2|page3|..... wikk created .... if some one clicks a page.

at server , php files first

$start-from=$_GET['pageno']
$finish= $start-from * $ noofimage;
$start-from=($start-from -1)* $ noofimage 

// we are using startfrom- 1 because , in next page images should start from 30 to 60. so we get a page multiple it with noofimages per page for $finish and for start we just decrement 1 then multiple it with noofimage.

now , use php mysql query to (start from , end);

// I just shared a idea how to do php for this page. try it , or ask if you have any problems.

Raj
  • 159
  • 1
  • 1
  • 11