In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> Is it Possible, in PHP to read a URL?
>
> What I am trying to do is this...
> I have many news stories in a database, and a single static news page, that
> calls the story, and the corresponding headline.
> I have looked about on-line, and seen a common URL,...
>
> http://www.arandomsite.com/news_story.php?id=123
>
> I have adopted this method, and it only displays the top most story in my
> database, no matter what news ID I use.
>
> Can I get the ID number from the URL?, and then pass that to the SQL
> statement?
Yes to both, and quite easily. All the variables passed in a GET request
(which is what the url is) will automatically be made available in the
$HTTP_GET_VARS associative array. So variable "id" is at
$HTTP_GET_VARS['id']. In addition, if the configuration setting
"register_globals" is turned on, the variable will also be accessible
simply as $id.
So in the script news_story.php, you could write a query string like, for
example:
"SELECT article_text from story_table where id=$id"
or
"SELECT article_text from story_table where id=" .
$HTTP_GET_VARS['id']
See <http://www.php.net/manual/en/language.variables.external.php>
--
CC
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]