manalnor Posted March 17, 2011 Share Posted March 17, 2011 Hello dear friends, Let say we have $space ="hello world"; then remove spaces between the words by using $title = str_replace(' ', '-', trim($space)); so it would be here as "hello-world" and let say we have stored title,article text...whever in an database table that call back all this using id then for an article with id=1 its link will be site.com/index.php?id=1 it is clear that the echo "$id"; //<--- 1 now some wordpress or/and blogs using rewrite .htaccess to make the link as site.com/$title-$id (as our example site.com/hello-world-1) then how they know its $id = 1 to get any variables from database that needs the id i've tried but never works and only works if i made something like site.com/$title_$id //<-- site.com/hello-word_1 cause it needs difference separate in order to understand the id so how to make it ? how to make it understand that the last separated is the id thanks Quote Link to comment https://forums.phpfreaks.com/topic/230907-link-id/ Share on other sites More sharing options...
gristoi Posted March 17, 2011 Share Posted March 17, 2011 The sites you are reffering to mainly use the MVC (Model View Controller) design pattern. this reflects in the URL. Each Controller has a set of Actions which take in the user parameters and pass them to the model etc.. Therefore if you are passing a variable through the url: // www.somewebsite.com/ControllerName/ActionName/Variable1Name/Variable1Value/Variable2Name/Variable2value // which translates looks like: // www.somewebsite.com/Loginpage/loguserin/myusername/name1/password/logmein obviuously you would not pass sensitive data like this, but i hope it explains it for you Quote Link to comment https://forums.phpfreaks.com/topic/230907-link-id/#findComment-1188639 Share on other sites More sharing options...
manalnor Posted March 19, 2011 Author Share Posted March 19, 2011 i found something... if we make url like this one-id.html <--- it works but for one-two-id.html <--- not working can't even know the id and for one-two_id.html <--- working this one can know the id how then i can set it like second one Quote Link to comment https://forums.phpfreaks.com/topic/230907-link-id/#findComment-1189585 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.