Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP passing requested post id and title in url but not showing id in the url Reply To: PHP passing requested post id and title in url but not showing id in the url

#146181
Jochim
Participant

@traq Thanks for the reply and…

Depends on how your database table is indexed – if you have an index on the title -and every title is unique- then no, it’s not a problem.

I have my database set up like this:

post_id (just an AUTO INCREMENT), 
post_title (not unique), 
post_url (unique and slug of post_title and if the slug already exists add '-2, -3, ...')

but I don’t really know what you mean by ‘an index on the title’ ? So I guess I don’t have it :) And oh ok if matching the post_url doesn’t make any noticeable difference in speed then I could do that.

If your DB is not indexed this way, you can create an index for it. This would be the simplest solution.

What exactly is the index that the code creates? Could you explain that a little more please?

instead of writing example.com/forums/category/post-id/post-title, write example.com/forums/category/post-title?id=post-id instead.

Isn’t that almost the same except swich the post_id and post_title around?

(Are you using WP (or some other CMS)?)

No I’m trying to make my own CMS, “it’s good practice” I told myself :) and I hope I can use it in a project once it’s finished..