Possible Duplicate:
PHP code to convert a MySQL query to CSV
Hi I am generating a csv file from mysql record seperated by "," comma. I fetch data from database and concate it in a string. I am using following code
for($i=0;$i<count($all_logs);$i++)
{
$rd=$project->fetchRow($project->select()->where('id='.$all_logs[$i]->user2project_id));
$username=$userid->fetchRow($userid->select()->where('id='.$all_logs[$i]->user_id));
$outstr .=$all_logs[$i]->log_date.",";
$outstr .=$username->username.",";
$outstr .=$rd->title.",";
$outstr .=$all_logs[$i]->task.",";
$outstr .=$all_logs[$i]->workdesc.",";
$outstr .=$all_logs[$i]->hours.",";
$outstr .="\n";
}
return $outstr;
Now what is my problem. If any column data is itself is having a " ," comma then it splits this 1 column to 2 columns. For example if my column workdesc is having data like this I worked on this,that,these and those then it will put this 1 column to 3 columns in generted csv. Any body can tell me how can I escape from this situation......