Include a page based on ID.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Burst404
Forum Newbie
Posts: 3
Joined: Wed Dec 10, 2008 11:38 pm

Include a page based on ID.

Post by Burst404 »

Now, I don't know if this is possible, but it would be awesome if it were...

I have a page, and I'd like to include an additional page using IDs...

Example:

example address:

Code: Select all

hxxp://www.example.com/image.php?id=2008-12-11a

code should then pull:

Code: Select all

<?php include("media/posts/(($ID)).php"); ?>
Whereas (($ID)) would be the id above...

Is this possible?

Thanks in advance.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Include a page based on ID.

Post by Eran »

yep, it's possible. Url parameters are stored in the superglobal $_GET array. Make sure to filter and validate any data passed through it as to avoid having your script exploited.
Burst404
Forum Newbie
Posts: 3
Joined: Wed Dec 10, 2008 11:38 pm

Re: Include a page based on ID.

Post by Burst404 »

What would be the code to do such a thing? To be honest, I'm rather new to PHP.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Include a page based on ID.

Post by Eran »

Google 'php $_GET tutorial' and get cracking. If you encounter problems while trying to learn, come back here and we'll help you with specific questions.
Burst404
Forum Newbie
Posts: 3
Joined: Wed Dec 10, 2008 11:38 pm

Re: Include a page based on ID.

Post by Burst404 »

Actually, thank you so much! I like to research my own code, but no matter what I searched for, google wouldn't return anything.

Again, thank you... I may be back...
Post Reply