jrws Posted August 24, 2010 Share Posted August 24, 2010 Hey there, That topic may be a little confusing to begin with so let me explain. I know how to make this url-> www.example.com/articles?id=1 into www.example.com/articles/1 But how would I extract the topic so instead of a number it is the title? Would I need to change what is extracted from the database? Cause I extract articles based on their IDs, but I want the URL to reflect their titles. Is that possible? I hope I have made sense, I don't really have any code to show, but if I can clarify on something, please ask and I will try. Thanks, James Quote Link to comment https://forums.phpfreaks.com/topic/211568-number-to-text/ Share on other sites More sharing options...
cags Posted August 24, 2010 Share Posted August 24, 2010 No it is not possible. You cannot have the title in the URL and extract from the database based on the ID without also having the ID in the URL. One approach that some sites use is to have /id-title and use a rule such as ^(\d+)-[a-zA-Z0-9-]+/?$. If you echo out your URIs in this style you then have the ID you need to query your database. The other approach, which leaves a cleaner URL (as you don't need the ID at all) is to add a permalink/slug field to your database and query the database based on that instead of ID. Quote Link to comment https://forums.phpfreaks.com/topic/211568-number-to-text/#findComment-1103060 Share on other sites More sharing options...
jrws Posted August 25, 2010 Author Share Posted August 25, 2010 Thought so. Thanks, for the tips. Quote Link to comment https://forums.phpfreaks.com/topic/211568-number-to-text/#findComment-1103397 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.