techker Posted December 3, 2010 Share Posted December 3, 2010 Hey guys i got my export page to work but it looks super ugly..lol first of i can separate the lines with txt and the colums are not adjusting to the txt in it? like information line hear information 2 line hear.. Where the spaces are i want text.. $csv_output = '"PERSONAL","INFORMATION"'; $csv_output .= "\015\012"; $result = mysql_query("select * from APPLICATIONS WHERE ID= '$ID'"); while($row = mysql_fetch_array($result)) { $csv_output .= '"'.$row[PERS_L_NAME].'","'.$row[PERS_F_NAME].'"'."\n"; $csv_output .= '"'.$row[PERS_DATE_BIRTH].'","'.$row[PERS_SSN].'"'."\n"; $csv_output .= '"'.$row[PERS_DRIVERS_L].'","'.$row[PERS_CODE].'"'."\n"; $csv_output .= '"'.$row[PERS_ADD].'","'.$row[PERS_CITY].'"'."\n"; $csv_output .= '"'.$row[PERS_ADD_2].'","'.$row[PERS_CITY_2].'","'.$row[PERS_CODE_2].'"'."\n"; $csv_output .= '"'.$row[PERS_NUMBER].'","'.$row[PERS_CELL].'","'.$row[PERS_FAX].'"'."\n"; $csv_output .= '"'.$row[EMPL_E].'","'.$row[EMPL_CITY].'"'."\n"; $csv_output .= '"'.$row[EMPL_ADD].'","'.$row[EMPL_CODE].'"'."\n"; $csv_output .= '"'.$row[EMPL_TYPE].'","'.$row[EMPL_SINCE].'"'."\n"; $csv_output .= '"'.$row[PERS_L_NAME].'","'.$row[PERS_F_NAME].'"'."\n"; $csv_output .= '"'.$row[EMPL_P].'","'.$row[EMPL_N].'"'."\n"; $csv_output .= '"'.$row[EMPL_SUP].'","'.$row[EMPL_GS].'"'."\n"; $csv_output .= '"'.$row[PERS_L_NAME].'","'.$row[PERS_F_NAME].'"'."\n"; $csv_output .= '"'.$row[EMPL_2_E].'","'.$row[EMPL_2_ADD].'"'."\n"; $csv_output .= '"'.$row[EMPL_2_CITY].'","'.$row[EMPL_2_CODE].'"'."\n"; $csv_output .= '"'.$row[EMPL_2_TYPE].'","'.$row[EMPL_2_SINCE].'"'."\n"; $csv_output .= '"'.$row[EMPL_2_P].'","'.$row[EMPL_2_N].'"'."\n"; $csv_output .= '"'.$row[EMPL_2_SUP].'","'.$row[EMPL_2_GS].'"'."\n"; $csv_output .= '"'.$row[OTHER_OWN_RENT].'","'.$row[OTHER_OWN_RENT_D].'","'.$row[OTHER_OWN_RENT_V].'","'.$row[OTHER_OWN_RENT_AM].'","'.$row[OTHER_OWN_RENT_MP].'"'."\n"; $csv_output .= '"'.$row[OTHER_CC_REER].'","'.$row[OTHER_CC_REER_D].'","'.$row[OTHER_CC_REER_V].'","'.$row[OTHER_CC_REER_AM].'","'.$row[OTHER_CC_REER_MP].'"'."\n"; $csv_output .= '"'.$row[OTHER_INV_CAR].'","'.$row[OTHER_INV_CAR_D].'","'.$row[OTHER_INV_CAR_V].'","'.$row[OTHER_INV_CAR_AM].'","'.$row[OTHER_INV_CAR_MP].'"'."\n"; $csv_output .= '"'.$row[OTHER_OTHER_L].'","'.$row[OTHER_OTHER_L_D].'","'.$row[OTHER_OTHER_L_V].'","'.$row[OTHER_OTHER_L_AM].'","'.$row[OTHER_OTHER_L_MP].'"'."\n"; $csv_output .= '"'.$row[email].'","'.$row[sTATUS].'"'."\n"; $csv_output .= '"'.$row[DATE].'","'.$row[ACCEPT].'"'."\n"; $csv_output .= "\015\012"; } //You cannot have the breaks in the same feed as the content. header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv; filename=document_" . date("Ymd") . ".csv"); print $csv_output; exit; Link to comment https://forums.phpfreaks.com/topic/220609-export-to-csv-line-break/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.