need a help please

Discussion in 'PHP' started by falcons, Nov 10, 2008.

  1. #1
    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
     
    falcons, Nov 10, 2008 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    export it from phpmyadmin if u have it ... or make ur own queries in php
     
    commandos, Nov 10, 2008 IP
  3. falcons

    falcons Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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
     
    falcons, Nov 10, 2008 IP
  4. intelrate

    intelrate Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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!
     
    intelrate, Nov 10, 2008 IP
  5. falcons

    falcons Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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
     
    falcons, Nov 11, 2008 IP
  6. intelrate

    intelrate Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The simplest way is just display a link to your file when it is written. Thus, user can download it from their browser.
     
    intelrate, Nov 11, 2008 IP
  7. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Christian Little, Nov 11, 2008 IP