0

Hello Everyone

Iam Exporting All My Data From Mysql To Txt File With This Code

    <?php
    $sql2 = mysql_query("SELECT * FROM export
    INTO OUTFILE '/Zero.txt'
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n'");
    ?>

I Need To Edit The Code So It Export The New Data I Insert In MySql Only (( Not All Data Again ))

diafol Helped Me With This Code

Have another field in export:
int(5?) called txtfile, default 0

When you're ready to create a new textfile:

$r = mysql_query("SELECT MAX('txtfile') + 1 AS nextval FROM export");
$d = mysql_fetch_assoc($r);
$nextval = $d['nextval'];
$r = mysql_query("SELECT * FROM export WHERE txtfile = 0
INTO OUTFILE '/Zero_$nextval.txt'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'");
$r = mysql_query("UPDATE export SET txtfile = $nextval WHERE txtfile = 0");

It Works Ok

I Need To Make The Same Idea But Without Creating Tables In The Database

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.