Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Posts
    120

    Unanswered: carriage return to <br>

    Hi to all........
    I have a 'product description' field in my 'MySQL' database, that is a 'text' type.
    I have imported thousands of product descriptions and can see the carriage returns when I view any given description through phpMyAdmin.
    These seem to be ignored by the HTML so I need to replace ALL carriage returns with a < /br> for every record in the description field.

    Is this possible? and if so, how could I do it?

    Many thanks in advance
    All the best
    Andy

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use one of the string functions such as replace in an update query if you want to get rid of the carriage returns in your data. or if you need to retian the carriage return then use the repalce function inside your select query

    you will need to check what the carriage return inside your data actually is. that depends on the original source of the data.
    some system use the ascii CR, some CR + LF and so on
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2008
    Posts
    120
    Hi healdem and thank you for your quick response.
    The original source of the data was a .csv file imported in to Magento (e-commerce solution).
    How do I find out which system was used?
    Thanks Again
    Andy

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    look at the data
    if its from a Microsoft OS then it will almost certainly be CR AND LF, its its from a Unix/Linux world its almost certainly just CR
    http://en.wikipedia.org/wiki/Newline

    This from would suggest you use something like
    Code:
    UPDATE xxxxxx set body = replace(body,'\r\n','');
    or
    Code:
    UPDATE xxxxxx set body = replace(body,'\n','');
    or you need to find what symbol(s) IS/ARE beeing used in your data and alter the replace statement accordingly
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2008
    Posts
    120
    Thank you again healdem
    That worked ferfectly and saved my many many hours manually formatting the description.

    :-) Big Smiles

    Andy

    PS I'd rather be riding my Busa ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •