Results 1 to 5 of 5

Thread: New Line in Code

  1. #1

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    New Line in Code

    I have a loop that brings some data down from a MySQL database, but it adds the code on the same line, right next to each other

    Is there a way of dropping a line in the code within each loop

    Thanks, ILMV

  2. #2
    New Member
    Join Date
    Apr 2006
    Posts
    15

    Re: New Line in Code

    yes!

    Where you want the line to break add ."\n"; to the end of your string.

    Failing that try ."<br />";

  3. #3

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: New Line in Code

    Worked great, i had seen that used before, never knew what it was.

    great work

  4. #4
    New Member
    Join Date
    Apr 2006
    Posts
    15

    Re: New Line in Code

    No prob!

    Obv. the more line breaks you want just keep adding \n\n etc within the quote ("") marks.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: New Line in Code

    How you implement a new line is completely dependent on the content type of the file being outputted. If you do not specify a content type by default, text/html is assumed which means you must serve a proper HTML document. If you just want to show raw data use the content type text/plain which saves you having to construct an HTML document. To make a line break in a text/plain document use the sequence "\r\n" (CR+LF) for maximum browser compatability.

    To specify content type, call the header() function before starting any output.
    PHP Code:
    header('Content-type: text/plain; charset: utf-8'); 

Posting Permissions

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



Click Here to Expand Forum to Full Width