How to export the data from php to CSV

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maheswaran
    New Member
    • Mar 2007
    • 190

    How to export the data from php to CSV

    Hi,

    i have no problem in export the data from php to csv. But i have struggled to put the <br> in of csv coloumn. Here the details
    Code:
    PostId    PostTitle   Reply                  Ip
    
    1         test        reply 1               127.0.0.1
                          reply 2
                          reply 3
    
    
    2         test2       response 1            127.0.0.1
                          response 2
    In the above example i have export the all the data's into csv. But in "Reply" column i can not give the <br> between the reply/response. How i can separate each reply's?
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Use strip_tags()

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      As far as I know, that isn't how CSV works. You have a row with columns and each field (column) or that row can have one entry, not multiple entries as you appear to desire; you'll have to make a new entry for each reply.
      Last edited by Markus; Oct 28 '10, 11:50 AM.

      Comment

      • maheswaran
        New Member
        • Mar 2007
        • 190

        #4
        strip_tags is not working for me. Here the my code

        Code:
        while ($rowr = mysql_fetch_row($values)) {
        	 
          for ($j=0;$j<$i;$j++) {
            $csv_output .= "\"".$rowr[$j]."\","; //Here i have generate PostId,PostTitle
        	 
          }
        		//echo $rowr[0]."<bR>";
        		$sql1='SELECT response 
        		FROM  ost_ticket,ost_ticket_response
        		WHERE ost_ticket.ticketID ="'.$rowr[0].'" AND ost_ticket.ticket_id=ost_ticket_response.ticket_id';
        
        		$values1=mysql_query($sql1);
        
        
        		while (list($response) = mysql_fetch_row($values1)) {
        			//$response=strip_tags($response,"<div>");
        			 $csv_output1 .= "\"".$response."\"";	/ Here i have created multiple response for a single post for a single column Reply- Reply should place next line or break in the same reply column				 
        		}
        
        		
        
        		
            $csv_output .= "\"".$rowr3[$j]."\",";
        
             $csv_output .= "\n";
        	 
          }

        Comment

        Working...