clay1 Posted January 30, 2010 Share Posted January 30, 2010 I am writing a script to export a table to excel for a client They have a column 'more_info' that they have brilliantly included html and javascript in. This is breaking the file when it's exported. Works fine until it hits the html and then the <br> screws up the rest of the file. I tried strip_tags but got the same result while($row_DetailRS1 = mysql_fetch_array($DetailRS1)){ for($i=0; $i< count($row_DetailRS1); $i++){ echo strip_tags($row_DetailRS1[$i]); if($i == count($row_DetailRS1)){ echo "\r"; } else {echo "\t";} } I suspect strip_tags won't work on an array? Ideas to fix this besides telling the client to get rid of the offending characters..? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/ Share on other sites More sharing options...
clay1 Posted January 30, 2010 Author Share Posted January 30, 2010 Or is this a problem more with my spreadsheet program? I'm using openoffice.org Is the php doing everything correctly but when I open the spreadsheet it's reading the html? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1004409 Share on other sites More sharing options...
clay1 Posted January 31, 2010 Author Share Posted January 31, 2010 Help? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1004645 Share on other sites More sharing options...
clay1 Posted February 1, 2010 Author Share Posted February 1, 2010 Maybe Monday morning will get a response? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1005064 Share on other sites More sharing options...
travis Posted February 1, 2010 Share Posted February 1, 2010 have you tried str_replace $row_DetailRS1[$i] = str_replace("<br>", "", $row_DetailRS1[$i]); ? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1005067 Share on other sites More sharing options...
clay1 Posted February 1, 2010 Author Share Posted February 1, 2010 I did this: $field = $row_DetailsRS1[$i]; $cleanfield = strip_tags($field); The html is removed when I just print to the screen. However the xls file is still borked. I emptied the field that was causing the problem and that row printed out fine. Then I removed the column altogether(I am using a copy of the table to test with) and the xls file only had 1 row. Very perplexing Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1005070 Share on other sites More sharing options...
clay1 Posted February 1, 2010 Author Share Posted February 1, 2010 OK. I've narrowed this down a bit I think. The problem being quotes in the html field. I am exporting to CSV now and this is what I am getting on a screen dump: http://,url" Click here . \" The URL is getting broken up into separate fields. The field in the table has both single and double quotes in it. How can I force those to be ignored? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1005131 Share on other sites More sharing options...
clay1 Posted February 1, 2010 Author Share Posted February 1, 2010 Changing my separator to \t and my encloser to ` fixed it-- is this my best solution? Link to comment https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/#findComment-1005158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.