jpipitone
asked on
Displaying dynamic PHP content from a page.
I have a website that I'm developing in PHP. I have 45 or so pages of content, each a paragraph long.
How can I organize these individual paragraphs and store them in one central location, and then as each PHP page is rendered - how can I pull the content from a page based on some sort of anchor link?
I've seen sites with this type of technology being used and the URL looks similar to:
http://www.servername.com/info.php?article=45
Is there a script out there that accomplishes this?
How can I organize these individual paragraphs and store them in one central location, and then as each PHP page is rendered - how can I pull the content from a page based on some sort of anchor link?
I've seen sites with this type of technology being used and the URL looks similar to:
http://www.servername.com/info.php?article=45
Is there a script out there that accomplishes this?
ASKER
I don't understand your English too well - can you describe to me in detail how I would organize the articles and the command used to grab the articles?
I'm assuming its something like <? php $_GET["1"] ?>
But how would I organize the content file?
I'm assuming its something like <? php $_GET["1"] ?>
But how would I organize the content file?
>> I'm assuming its something like <? php $_GET["1"] ?>
Yes
You can use a database to store the articles, and then get the corresponding one.
Yes
You can use a database to store the articles, and then get the corresponding one.
It would be $_GET['article'] (since that was the name part of the query string parameter: foo.php?name_of_parameter= value_of_p arameter)
And you would have to do something with it to get the article.
For example:
$subject = "abcdef";
$pattern = '/^def/';
<?php
if (isset($_GET['article']) && preg_match('/^\d+$/', $_GET['article']) {
include('/path/to/include/ files/arti cle_' . $_GET['article'] . '.txt');
}
?>
That should work, although my PHP is a little rusty. Note the test with the regular expression to ensure the article variable contains only digits - this prevents it being loaded up with "../" in order to access arbitary files on your file system.
And you would have to do something with it to get the article.
For example:
$subject = "abcdef";
$pattern = '/^def/';
<?php
if (isset($_GET['article']) && preg_match('/^\d+$/', $_GET['article']) {
include('/path/to/include/
}
?>
That should work, although my PHP is a little rusty. Note the test with the regular expression to ensure the article variable contains only digits - this prevents it being loaded up with "../" in order to access arbitary files on your file system.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you have to goto the new page, give the location as .... (in JS)
"http://www.servername.com/info.php?article=" + yourid
Then in PHP, you can recieve the id using $_GET["article"]
Bye
---
Harish