/    Sign up×
Community /Pin to ProfileBookmark

PHP links like index.php?id=1, how to?

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

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@nevaliteauthorFeb 05.2006 — Anyone?
Copy linkTweet thisAlerts:
@NogDogFeb 05.2006 — 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.)
Copy linkTweet thisAlerts:
@cafrowFeb 05.2006 — 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.)[/QUOTE]

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.
Copy linkTweet thisAlerts:
@nevaliteauthorFeb 05.2006 — 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.
Copy linkTweet thisAlerts:
@NogDogFeb 05.2006 — "Everyone" might be a bit extreme: [i]I[/i] don't do that. ?
Copy linkTweet thisAlerts:
@bokehFeb 05.2006 — 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.)[/QUOTE][URL=http://www.straightdope.com/mailbag/mhear.html]Hear hear![/URL]
Copy linkTweet thisAlerts:
@CytaelFeb 05.2006 — 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
[code=php]
<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>
[/code]
×

Success!

Help @nevalite spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...