runspace Posted February 10, 2007 Share Posted February 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
Hypnos Posted February 10, 2007 Share Posted February 10, 2007 The best way to do this is with mod_rewrite, if you're using apache. You can have... http://mysite.com/test/1234 rewrite to... http://mysite.com/test.php?number=1234 http://www.workingwith.me.uk/articles/scripting/mod_rewrite Quote Link to comment Share on other sites More sharing options...
runspace Posted February 11, 2007 Author Share Posted February 11, 2007 what other ways can I go about doing this? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2007 Share Posted February 11, 2007 mod_rewrite is the best way, that's kind of what it's meant for. Quote Link to comment Share on other sites More sharing options...
runspace Posted February 11, 2007 Author Share Posted February 11, 2007 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? Quote Link to comment Share on other sites More sharing options...
runspace Posted February 11, 2007 Author Share Posted February 11, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.