Jump to content

[SOLVED] Multipurpose Pages


thomashw

Recommended Posts

Whenever I go to a website that uses a database, the URL is something like this (the URL for a page other than index.php, I mean):

http://www.website.ca/index.php?somethingid=80

 

The pages never seem to leave index.php, but just use a specific id (such as product, manufacturer, etc.)

 

Is the goal to have ONE multipurpose page called index.php which contains all the html and php code for your website? Or is it okay to have seperate pages to seperate your code (and maybe make it a tad easier?)

 

I'm completely new to this, so if this is a dumb question I apologize.

 

Thanks!

Link to comment
Share on other sites

You'll actually find that most places do have lots of different pages. They use whats known as mod_rewrite to tell the webserver which page has been requested. For example, say i have a site and a link to it is: example.com/articles/10015/

 

I could use mod_rewrite to make that url link to: example.com/articles.php?id=10015

 

Now, i know you mentioned using index.php, but the same sort of thing applies.

 

Alternative methods are to use index.php to include various other pages based on the url:

 

<?php
$page = $_GET['page'];
include($page.'.php');

 

Or to use the parameters passed in the url to select content from the database.

 

So, in short, no -there is nothing wrong with a more tradional approach of completely separate pages. People use the above methods for many reasons, includig easy of layout change, and search engine optimization. But unless you have a big site, then there's probably not a lot to worry about.

Link to comment
Share on other sites

ok....

 

 

sure:

 

index.php

home.php

contact.php etc will all work..

 

the other way to do it is like this:

 

index.php?id=1

 

then in index.php:

 

 

if($_GET['id'] == 1) {  then do one page.  usually built rhoguh :

 

if($_GET['id'] == 1) {require('page1.inc'); }

 

then you build your pages in page1. - but it appears to be index.php

 

 

hope that helps you to understand

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.