How to Export MySQL Table data as CSV file in PHP

ID Username Name Gender Email
1 yssyogesh Yogesh singh male yogesh@makitweb.com
2 sonarika Sonarika Bhadoria female bsonarika@gmail.com
3 vishal Vishal sahu male vishal@yahoo.com
4 sunil sunil male sunil521@gmail.com