Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/211568-number-to-text/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/211568-number-to-text/#findComment-1103060
Share on other sites

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.