Jump to content

Recommended Posts

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?.

Link to comment
https://forums.phpfreaks.com/topic/144435-how-i-get-mysql-records-without-id/
Share on other sites

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>

 

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.

 

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.

 

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.

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.