/    Sign up×
Community /Pin to ProfileBookmark

How to build php?id

Hello, I’m sort of new to using PHP. I am trying to build a news feature into the website I am currently working on and I have noticed some sites which use PHP have their news articles posted as an id. specifically the url extension is .php?id=’number’. I was wondering if anybody had some information or good sources I could read which would help me do this within my own site.

Thanks!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@TecBratMay 02.2011 — A lot of those sites are pulling their data off of a database so the id is a field out of that database. That ID would be assigned to a variable and when you make the link to that news item you'd do something like:[code=php]
echo('<a href="http://www.myreallycoolsite.com/index.php?id='.$id.'">'.$news_title.'</a>');
[/code]


Then index.php has to access $_GET['id'] and retreive the correct news item to display.

HTH.
Copy linkTweet thisAlerts:
@TheClydeauthorMay 02.2011 — Ack....I was afraid thats what it would be. We have asked for access to a database but we have been denied. On that note, is there any other efficient way that I would be able to create a similar system?
Copy linkTweet thisAlerts:
@TecBratMay 02.2011 — You can use flat files to emulate a database. Do a google search for "php flatfile database" and you'll get lots of info.

You can also hand create them and hand create your urls. Maybe put each news item in a seperate file and keep an array of available files with an ID for each file in the array. Then include the file that matches up with the element in the array.
×

Success!

Help @TheClyde 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...