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

Instead of writing the value to database, you can write it to file, but it has to be stored somewhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.