helle i am new in fourm and also in php i want to create a csv file.. i want to export the data from MYSQL to a CSV file and download into the local system ... so please help me thanks in advance
this i am doing already ... but this a manual way to copy the data from database... i want to do this in just one click and download all data ... so you have already make a CSV file by using php code then please help me
Hey! If you really want to use PHP for this task, I'll tell you how to. SCV is just a text file consisting of lines. First line is header containing column names. Next lines contain data. Columns are separated by customized symbol. Strings may be enclosed in quotes. Let's review it on the sample: "Customer name"|"Customer e-mail"|"Customer address" "James Bond"|"james@bond.ru"|"First Oak street, 007" "John Smith"|"john@smith.com"|"Last Oak street, 1" Here are steps to load this data from your database and write it into file: 1) Connect to the data manager (mysql_connect) 2) Select your DB (mysql_select_db) 3) Prepare Query ("SELECT `NAME`, `EMAIL`, `ADDRESS` FROM `Customer`" for instance) 4) Run this query (mysql_query) 5) Open file to write into (fopen) 6) Write column names into first line (fwrite) 7) Retrieve data from the result of your query in cycle: (mysql_fetch_array) 8) Write values into your file: one iteration - one line. 9) Close your file (fclose) 10) Close connection to database (mysql_close) Everyone can easily help you but you have to perform each step yourself If want to become better in PHP. Use names of functions to find documentation in Google. In case of troubles, feel free to ask for advice. Good luck!
dear intelrate thank you very much i had done it meanz i write the code that is make a csv file.... with the fallowing your instration and staps.. thanks again .. one think tell me please that how to download that CSV file from net to local system ... meanz when i click on export botten then after making that file will be copy in my system .. like i have lot of IDs in my hotmail contect list... so if i want to export all my contect list in a csv file then that will be copy in my system .... i want do this .... so how i do it .. guide me please
The simplest way is just display a link to your file when it is written. Thus, user can download it from their browser.
I posted the entire code on how to do this on my blog last week, you can download the code here: http://www.christianlittle.com/web-development/php-code-to-turn-any-mysql-query-into-a-csv-file/ Once the file is created, you can just tell php to mail it off or do whatever you want with it.