Function for making url-friendly strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luttkens
    New Member
    • Jul 2007
    • 23

    #1

    Function for making url-friendly strings

    I'm using MySql on a web server. Iv''e got at table with diffrent catgories, where some of the category has non-url-supported charcters such as &, : åäö, etc.

    I'd like function that turns all non-url-supported-characters into a '-'. For instance: Me & My Friends -> me-my-friends.

    I know that I can make another table with "url-name" but that's not a good solution for med. I would also like to avoid using the REPLACE function for every non-supported chacter.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I would not do this using MySQL.
    This is more of a front-end sort of thing.

    You should try to avoid "pre-encoding" your data to fit your front-end, but rather store it as it is and "encode" it when it is to be used.

    Not to mention that most front-end languages used for web-development have functions to do things like this.
    Like PHP's urlencode function, for example.

    Comment

    Working...