Click to See Complete Forum and Search --> : PHP links like index.php?id=1, how to?
nevalite
02-05-2006, 09:55 AM
Hello,
My new site isnt really php im just using .php extensions so I can use includes. All the sites I see using index.php have the other pages on their site linked like this: index.php?id=1 or index.php?id=2,3 etc. How can I do that with my pages instead of having to make a new name for every page like, index.php and coolstuff.php.
Thanks
nevalite
02-05-2006, 10:38 AM
Anyone?
NogDog
02-05-2006, 11:07 AM
First question to ask is, why do you want to do that? Unless you're intending to extract the various pages from a database, you still have to create individually named files for each page. So why not just link to them normally instead of adding an additional layer of server-side processing? (Plus, I think such indirect linking can be confusing to search engines.)
cafrow
02-05-2006, 11:19 AM
First question to ask is, why do you want to do that? Unless you're intending to extract the various pages from a database, you still have to create individually named files for each page. So why not just link to them normally instead of adding an additional layer of server-side processing? (Plus, I think such indirect linking can be confusing to search engines.)
I agree with NodDog, for the sake of SEO and such i would include the header, nav and foot of the site, but leave the main content alone, use CSS for the graphics and layout that way most changes to the site will be in the include files and CSS. When I first started programming I would do what you are talking about, which is make 1 page and the rest is stored in the database, it get tricky and ungly after a while.
nevalite
02-05-2006, 11:19 AM
You are right I think I will just name them normally, I just thought since everyone else had it set up that way their must be an advantage.
NogDog
02-05-2006, 12:11 PM
"Everyone" might be a bit extreme: I don't do that. :)
bokeh
02-05-2006, 12:40 PM
First question to ask is, why do you want to do that? Unless you're intending to extract the various pages from a database, you still have to create individually named files for each page. So why not just link to them normally instead of adding an additional layer of server-side processing? (Plus, I think such indirect linking can be confusing to search engines.)Hear hear! (http://www.straightdope.com/mailbag/mhear.html)
Cytael
02-05-2006, 04:26 PM
I personally like this way of doing things, though it's probably not too great for SEO. Links using this code would point to something like index.php?page=page1
<body>
<div id="header">header stuff</div>
...
<div id="content">
<?php
switch($_GET["page"]) // get value of page= from URL
{
case "page1": require("page1.html"); break;
case "page2": require("page2.html"); break;
default: require("page0.html");
}
?>
</div>
...
<div id="footer">footer stuff</div>
</body>