Clear SQL table before importing data (php)

Started by Azoula, May 19, 2015, 10:58:01 AM

Previous topic - Next topic

Azoula

Hi guys as the title says i'm trying to clear My SQL table before importing new data , but the problem only the last two rows appears not all of them .

I tried this using "TRUNCATE"

Code (php) Select
// clear table
$sqli = "TRUNCATE TABLE MyTable";
mysql_query($sqli);


$sql = 'INSERT INTO MyTable VALUES("'.$Data1.'","'.$Data2.'") ';
mysql_query($sql);
mysql_close();


when i use something like that

Code (php) Select
$sql = 'SELECT * FROM MyTable';
    $req = mysql_query($sql);
    while($data = mysql_fetch_array($req)){
        $D1 = $data['data1'];
        $D2 = $data['data2'];
        echo "$D1<br />
        $D2<br />";
    }


i can see only the last two rows.

Advertisement: