Answer the question
In order to leave comments, you need to log in
How to make CNC without id?
There is a URL like site.ru/book?id=1. And I want to do this: site.ru/book/php-dlya-chajnikov.
The content of the page is retrieved from the database by id. I don't want to add an ID to the end of the address.
I see two possible solutions:
1. Pass id via POST
I don’t even know how to implement it, because I don’t want to register a hundred times 2. Display from the database by id like “php-dlya-chajnikov”.form method="post"
SELECT id, title, author FROM books WHERE id='php-dlya-chajnikov'
Answer the question
In order to leave comments, you need to log in
It's called a bicycle.
The problem is solved very simply:
"site.ru/book/php-dlya-chajnikov" - this part of "php-dlya-chajnikov" is called "slug".
An additional slug field is created in the database, where, when creating a record, the abbreviated name of the post is automatically or manually written.
Then we just do a selection on it:
SELECT id, title, author FROM books WHERE slug='php-dlya-chajnikov'
Here, in my opinion, the speed will be low.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question