How to fetch the database record of a parameterized string without using the id

Hi guys,

I need your help with getting the database record of a parameterized string without using the id.

For instance, I have a link www.mylink/product/this-product-is-good and would like to get the details of this-product-is-good

Would really appreciate any help that will come my way.

Thanks

You still need some kind of “id” for this.
In your example such id would be “this-product-is-good”.
It means you have to store those text keys (SLUGs) for each product and query the database using text key instead of normal auto increment id.

Your table would look like:

id  | title            | slug
---------------------------------------
1   | First Product    | first-product
2   | Second Product   | second-product

and query:

SELECT * FROM products WHERE slug = 'first-product'

THANKS A BILLION MEGAZOID!!! I really appreciate you. Hope you wouldn’t mind to drop me your email address. I need great men like you around me!

You can always find me here :wink:

Maybe add a top1 in case you only need to show one record.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.