SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: data in mysql

  1. #1
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when I pull my data from my database and print it to the web page I don't have all the carriage return and new lines I want. If I browse the data in phpMyAdmin I don't see any of the breaks. If I view the table dump in cvs it shows the linebreaks where they should be.

    Can anyone tell me what I need to do to show the linebreaks when I print the data to the web page?

    Thanks.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is because html does not recognize carriage returns and line breaks so you need to change those to <br> tags before you insert into the db, because ascii does aafter yo uexport to cvs and view it notepad or whatever you view it in they will appea again. And becuase phpMyAdmin uses a web browser you won't see them either.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great! Thanks! I'm mightly pleased with how my site is coming along. Once I am done I will post the url for all to view.

  4. #4
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to edit the data again in a text box <textarea> you will need to remove the <br> and replace them with line feeds again to get the formating back. So you would be much better using nl2br() on the data when you pull it from the database.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Karl I am not sure I follow you advice if you use nl2br() when pulling it from your db and put it in a textarea you should have the text with <br> tags and not line breaks unless I am horribly mistaken. The reason he doesn't see it phpMyAdmin is because it runs stripslashes before it puts the data anywhere(the screen and such) which would remove newlines; so my opinion to him is to just run the nl2br() only when he prints it to the screen that way the data will always have the newlines in tact.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm entering the data into my database with <br> tags and when pulling the data back out to go on the page I am just pulling straight from that field. It works like a charm.

    It's all song lyrics so it won't change. I won't need to edit it. I'll mostly be adding more.

    Thanks for the help everyone...it is all coming along beautifully.

    no domain name pointing there yet, but to get an idea: http://64.177.51.108.

    ps. I'm female


Bookmarks

Posting Permissions

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