Jump to content

Request url, extract portion and query mysql for extracted portion


runspace

Recommended Posts

I'm looking to do the following.

 

1. Request URL of current page

 

e.g.

http://mysite.com/test/1234

 

should I use

<?php $_GET['url']; ?>

?

 

2. I then want only the "1234" portion. 

 

3. I want the "1234" portion to be equal to a variable.

 

so

$variable = "1234";

 

4. I want to compare 1234 to database entries if any exist and and then get information about 1234 say address, headline

 

so $query = "SELECT address, headline * FROM database WHERE variable = '$variable'";

 

5. store the address and headline as separate variables.

 

$array['headline'] = $headline;

$array['address'] = $address;

 

****

 

Other portion to evaluate page and display title.

 

1. Get URL and if it's of the form "http://mysite.com/test/1234" complete the steps above and create a title with the headline from the database corresponding to 1234. 

 

 

 

 

Link to comment
Share on other sites

I think one of the other developers I work with already uses mod_rewrite to change to this path from a path where the variables are passed in the url.  I don't have access to the apache and believe the pages were changed to this path on purpose (for ease of use on the users end and to make more se friendly).  If I don't want to change the url is there another way I can evaluate pages and display relevant titles?

Link to comment
Share on other sites

I don't have access to the apache server although in the article hypnos posted it says I don't need to. I believe the links were changed to this path on purpose (without the variables being passed for ease of use on the users end and to make more se friendly). 

 

How can I find existing .htaccess files using FTP as I know we have some but don't see them showing up?

 

If I don't want to change the url using mod_rewrite is there another way I can evaluate pages and display relevant titles?

 

I was thinking of strpos php function to get the part of the url I need (the # after test).  I don't think I would be able to evaluate the current url though using this method as I'm currently doing by checking for variables passed. 

 

 

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.