Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:33:49+00:00 2026-05-26T05:33:49+00:00

Using PHP to extract data from SQL and then creating a .csv file on

  • 0

Using PHP to extract data from SQL and then creating a .csv file on the server for emailing/download by way of fputcsv. All works well other than trying to get a new line within a field in Excel (2003).

I get Product1Product2Product3 in the cell when I need

Product1
Product2
Product3

I have tried single quotes, double quotes, CRs, LFs and I am rapidly disapearing up my own backside.

So the question is – what character do I need to get into the CSV file to achieve this?

It has to work in Excel

[Solution] – the problem lay somewhere in passing the \r\n to Excel through the PHP fputcsv – I was unable to achieve this in any sort of fashion (plenty of appending the desired \r\n to my actual cell data e.g. Product1\r\n)
The suggestion to use $lfcr = chr(10) . chr(13); worked first time around. I guess this was more of a PHP rather than an Excel question – thanks to all resonses.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:33:49+00:00Added an answer on May 26, 2026 at 5:33 am

    This is more of an excel rather than a php question. What you put into the csv file needs to be understood by excel which is why \r\n will not work.

    Use this

    $lfcr = chr(10) . chr(13);
    

    Then append $lfcr to the end of each line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP to extract data from a MySQL database. I am able to
I'm using the PHP QueryPath library to extract data from a collection of old
I'm trying to create a procedure which extracts data from a MySQL server (using
i m using php file for using data in my application, in this file
I want to use PHP (possibly with Curl/XPath?) to extract data from Wikipedia pages.
I'd like to extract the content from a large file of table cells using
I'm trying a query in PHP to connect and extract data from a MSSQL
Using PHP, what's the fastest way to convert a string like this: 123 to
I have an app using PHP and the PayPal API. The basic way it
I'm using PHP 5.2. I'd like to find a way to output a unique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.