nivas_kumar Posted February 9, 2009 Share Posted February 9, 2009 hi i am beginners in php & mysql. Now i am doing one dynamic website. In this project i passing countryid(unique) from some pages to another page name countrydetails.php in this page i get countryid and then display country details using PHP GET method but how i change this process without using countryid. if any changes in htaccess file?. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/ Share on other sites More sharing options...
ratcateme Posted February 9, 2009 Share Posted February 9, 2009 what do you mean do you not want to pass the countryid in the url? you can use $_POST or $_SESSION but it sounds like $_GET is the best way Scott. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757908 Share on other sites More sharing options...
nivas_kumar Posted February 9, 2009 Author Share Posted February 9, 2009 Fine, But I am having many links with countryid for example countrylisting.php page displays country list from table “country”. So I am display like following link <a href=” countrydetails.php?countryid=20”> srilanka</a> So that countrydetails.php page I am using $_GET[“countryid”] . I can get srilanka details using following URL <a href=” countrydetails.php?srilanka”> srilanka</a> If passible, how I pass and get multiple values from following liks. <a href=” countrydetails.php?countryid=20&status=1”> srilanka</a> Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757925 Share on other sites More sharing options...
ratcateme Posted February 9, 2009 Share Posted February 9, 2009 for <a href=” countrydetails.php?countryid=20&status=1”> srilanka</a> you could use $_GET['countryid'] and $_GET['status']; Scott. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757928 Share on other sites More sharing options...
nivas_kumar Posted February 9, 2009 Author Share Posted February 9, 2009 If any ways to get $_GET['countryid'] and $_GET['status'] values from following url <a href='countrydetails/srilanka/1'>srilanka</a> Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757942 Share on other sites More sharing options...
ratcateme Posted February 9, 2009 Share Posted February 9, 2009 check out this thread for more details but you are looking at mod_rewrite http://www.phpfreaks.com/forums/index.php/topic,126435.0.html basically you want this in a .htaccess file RewriteEngine on RewriteRule ^ countrydetails/([^/\.]+)/([^/\.]+)$ countrydetails.php?$1&status=$2 [L] putting that in a .htaccess file everytime a url like countrydetails/srilanka/1 is called php $_GET gets filled in so the server sees countrydetails.php?srilanka&status=1 Scott. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757945 Share on other sites More sharing options...
nivas_kumar Posted February 9, 2009 Author Share Posted February 9, 2009 Thanks Scott. Lot of thanks to you.. I am Checking now.. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-757996 Share on other sites More sharing options...
nivas_kumar Posted February 9, 2009 Author Share Posted February 9, 2009 It is working . I am having a problem when I use following url result displays correctly but css and images not load. I mean if i access the page using following url http://www.mysite.com/countrydetails/2 in htacess file: ----------------------------------- RewriteEngine on RewriteBase / RewriteRule ^ countrydetails /([0-9]+)$ countrydetails.php?country=$1 [L] ------------------------------------ css and images not displays. If I put real URL [countrydetails.php?country=2 ] displays correct result with images and css. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-758076 Share on other sites More sharing options...
ratcateme Posted February 9, 2009 Share Posted February 9, 2009 someone was having this problem just a couple pf days ago when you add a rewrite like this the URLs change so where you had a image URL "images/top.gif" the browser turns it into "http://www.mysite.com/images/top.gif" so when you have a page at "http://www.mysite.com/countrydetails/2" the image URL is at "http://www.mysite.com/countrydetails/2/images/top.gif" to fix this you need to add a "/" to the front of the URL so you image and css links should look like this "/images/top.gif" that way when the page is at "http://www.mysite.com/countrydetails/2" it loads "http://www.mysite.com/images/top.gif" this also applies to all your links and ajax calls Scott. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-758330 Share on other sites More sharing options...
nivas_kumar Posted February 11, 2009 Author Share Posted February 11, 2009 Good, I changed path as you mentioned above, now my site is working fine. Thanks for proper explanation and thanks phpfreaks for the opportunity. Thank you Scott. Quote Link to comment https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/#findComment-759490 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.