I have a group of database records (without auto_increment identifiers or something else like that) displayed as a list, and it turns out that I need to distinguish each of them using a unique one id.
I could just add a working counter to the loop and do with it, but, unfortunately, this identifier should be a cross-link to the entire site, however the list is ordered or filtered.
Therefore, I had the idea to include the title of the record as part id(with a prefix so that it does not interfere with layout elements).
How to convert a string to a name idin a reliable way so that it never contains characters that could break HTML or not work as valid CSS selectors?
For instance:
Title ==> prefix_title
TPS Report 2010 ==> prefix_tps_report_2010
Mike "Proposal" ==> prefix_mikes_proposal
The headers are always diverse enough to avoid conflicts and will never contain non-western characters.
Thank!
source
share