Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to generate CSV with custom headers like USRNAME , USER PROFILE , EMAIL .

This is the code I am using .

$path = getcwd() . '/uploads/data.csv' ;
$sql = "select username, CONCAT('<a href ="$profile',username,'">',username,'</a>') as profile_url ,email  from `engine4_user` LIMIT 5000 into outfile '$path' FIELDS TERMINATED BY ','  LINES TERMINATED BY '
' ";

But I don't know how to add custom header , Or a custom row before the DB values. Please help me to add those fields .

I wants a CSV that will out put like:
USERNAME , PROFILE , EMAIL 
Jonson1 , http://mysite/profile/jonson1 , jonson.test1@gmail.com
Jonson2 , http://mysite/profile/jonson2 , jonson.test2@gmail.com
Jonson3 , http://mysite/profile/jonson3 , jonson.test3@gmail.com
Jonson4 , http://mysite/profile/jonson4 , jonson.test4@gmail.com

Now I generate :
Jonson1 , http://mysite/profile/jonson1 , jonson.test1@gmail.com
Jonson2 , http://mysite/profile/jonson2 , jonson.test2@gmail.com
Jonson3 , http://mysite/profile/jonson3 , jonson.test3@gmail.com
Jonson4 , http://mysite/profile/jonson4 , jonson.test4@gmail.com

I need to add 
USERNAME , PROFILE , EMAIL 

Thank You in advance .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
266 views
Welcome To Ask or Share your Answers For Others

1 Answer

Add headers using fputcsv() of php...Click for Reference


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...