"Moving" an entry from one table to another
Posted: Wed May 31, 2006 3:19 pm
Hi,i was wondering what would be the best way to move a recored from one table to another one:
i have thought of this way so far,but i think there maybe a more efficent way?
i have thought of this way so far,but i think there maybe a more efficent way?
Code: Select all
$act = $_GET['act'];
$entry = $_GET['entry'];//the id of the entry
if($act == 'approve') {
$query = "SELECT * FROM poffers WHERE id=$entry";
$result = mysql_query($query);
$data = mysql_fetch_array($result,MYSQL_ASSOC);
$sql2 = "INSERT INTO coffers (username,offer_name) VALUES ('$data['username']' , '$data['offer_name']' , '$data['offer_type']')";
$sql2run = mysql_query($sql2);
//remove it from the old table
$delete = "DELETE FROM poffers WHERE id=$entry LIMIT 1";
$delrun = mysql_query($delete);
$hits = mysql_num_rows($delrun);
if($hits == '1') {
echo 'The offer' .$entry.'has been removed from pending offers and has been moved to completed offers.';
}
}
}
?>