I have a news system, and we need you to access the details of the news from a link that will take the title of the news, not the news ID database.
Note: Some published news have words and letters with special characters, for example:
News title: $title = Nuevo demo de la canción de ñandú;
This title explode with PHP to remove hyphens and spaces would be as follows.
Explode title: $title_explode = explode(' ','-', $title);
Looks like this: $title_filter = nuevo-demo-de-la-canción-de-ñandú;
I created in the database a field title in this field the $title
will be saved, and I have another field within the database, title_filter, where would place the title $title_filter
, which it is the title that exploit, and would be saved also in the database, but we have a ñ and accented letters as we can to query the database to bring me to this record smoothly comparison.
Query: $sql = SELECT * FROM news WHERE title = $title_filter;
Domain with the news: www.dominio.com/nuevo-demo-de-la-canción-de-ñandú
My questions:
- This search is effective?
- You can optimize and remove accents $ title to make it so:
$title_filter = nuevo-demo-de-la-cancion-de-nandu;
- Worth create the additional field of the database title_filter to saved clean and do the title search on that title.
Note: The idea of not using the word ID to search the database is to have cleaner seo links and improve the website.
I hope you have understood me and can help me solve this dilemma and make database query data more effective.