Jump to content

Recommended Posts

Hi,

 

I am new to PHP and I am lookig for more information on the formating strings for example \n\r

 

I was trying to find them on google to read more about them but not sure what to search for.

 

Could somone please tell me where I can find some more information on this.

 

or maybe yo ucan help me with my issue.

 

I created thsi function and I want to clean up a comment field from ? and ,s but I want it to continue the line.

it is creating a new line when I try to convert it to an Excel .csv file.

 

Thanks

 

 

 

Here is my code:

<center><h1><img border="0" src="banner.gif" width="805" height="70"></h1>

<h1>Survey Results</h1></center>

 

<?php

function cleancomm($comm)

  {

    $comm1 = str_replace('?', ' ', $comm);

    $comm2 = str_replace(',', ' ', $comm1);

    return $comm2;

  }

 

require 'config.php';

require 'opendb.php';

 

$fp = fopen('file.csv','wa');

$q = 'select * from survey';

$query = mysql_query($q);

while ($row = mysql_fetch_array($query)) {

$nextline = $row[0] . ',' . $row[1] . ',' . $row[2] . $row[3] . ',' . $row[4] . ',' . $row[5] . ',' . $row[6] . ',' . $row[7] . ',' .

            $row[8] . ',' . $row[9] . ',' . $row[10] . ',' . $row[11] . ','. $row[12] .',' . cleancomm($row[13]) . ',' . cleancomm($row[14]) . "\r\n";

 

 

 

fwrite($fp,$nextline);

}

fclose($fp);

?>

Link to comment
https://forums.phpfreaks.com/topic/56273-formatting-question/
Share on other sites

I have the \r\n at the end of the line but in the comment field it is cutting it and adding multiple rows for each part where it cleans the field of "?" and ","'s.  Not sure what the problem is???

 

cleancomm($row[14]) . "\r\n";

 

I think the problem is when I strip it of all the ? and ,'s it just cuts it.  I would like to know how I can get the whold comment to stay together before the next line or row.

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/56273-formatting-question/#findComment-278477
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.