Create a CSV File for a user in PHP

前端 未结 19 2116
故里飘歌
故里飘歌 2020-11-22 11:52

I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.

I have the e-mailing of the link, MySQL query, etc. covered.

<
19条回答
  •  醉话见心
    2020-11-22 12:27

    Instead of:

    $query = "SELECT * FROM customers WHERE created>='{$start} 00:00:00'  AND created<='{$end} 23:59:59'   ORDER BY id";
    $select_c = mysql_query($query) or die(mysql_error()); 
    
    while ($row = mysql_fetch_array($select_c, MYSQL_ASSOC))
    {
        $result.="{$row['email']},";
        $result.="\n";
        echo $result;
    }
    

    Use:

    $query = "SELECT * FROM customers WHERE created>='{$start} 00:00:00'  AND created<='{$end} 23:59:59'   ORDER BY id";
    $select_c = mysql_query($query) or die(mysql_error()); 
    
    while ($row = mysql_fetch_array($select_c, MYSQL_ASSOC))
    {
        echo implode(",", $row)."\n";
    }
    

提交回复
热议问题