Jump to content

grab info from url


ohdang888

Recommended Posts

ok so sometimes on sites you see this:

 

http://www.mywebsite.com/blog/234522/This-is-a-blog-about-blogs

 

so the blog id is 234522, and the title is This-is-a-blog-about-blogs

 

so instead of looking for the 234522 folder, it has it set so it won't go to the folder, but rather the "blog" folder, then grabs the info from the url...

 

i know this can be done like id=234526&title=this is the title

 

but how do you do it that other way???

 

Thanks.

 

Link to comment
Share on other sites

Ok, I had this brilliant idea a little while back. But I have a bad feeling that using mod_rewrite is a lot safer.

 

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

$whatever_ID = curPageURL();

$whatever_ID2 = explode('/',$whatever_ID);

 

Basically you store the url into an array with that function. Then you simply explode that array and pull the data from it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.