Jump to content

Recommended Posts

I want to move the row from OLD TABLE to NEW TABLE where:
the OLD TABLE, status == 'S' & the dateModify is over a week, move that row (all data to the NEW TABLE).
Then delete that row on the OLD TABLE.
I try the code below, nothing happen, no data is output. I try to change to +1 day, it's still same but it should display the data a day old.

How can I fix that?

[code]
<?php include("config.php"); ?>
<?php
//INFO from mySQL
//id INT NOT NULL AUTO_INCREMENT,
//PRIMARY KEY(id),
//name VARCHAR(30),
//status VARCHAR(1),
//dateModify TIMESTAMP,  
$overWeek=date('Y-m-d H:i:s', strtotime('+1 week'));
$statusCheck="S";
mysql_select_db($dbnameNAME) or die(mysql_error());

$result = mysql_query("INSERT INTO $tableNEW
        (name, status, dateModify)
        SELECT name,status,dateModify FROM $tableOLD WHERE status = '$statusCheck' AND dateModify >= '$overWeek' " )
    or die($errCon . mysql_error());  

?>

<?php

mysql_select_db($dbnameNAME) or die(mysql_error());
$result2 = mysql_query("SELECT * FROM $tableNEW ")
or die(mysql_error());

while($row2 = mysql_fetch_array($result2)) {

    echo $row2['name'];
    echo $row2['status'];
    echo $row2['dateModify'];

}

//free up memory
mysql_free_result($result2);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/5659-move-data-from-table-to-another/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.