why don't you just use a field in the table telling whether or not its archived. just add an archive column with a 0 or 1. where 0 means not archived and 1 means it is.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
i don't think i understand what you are trying to do correctly. please give a more detailed explaination.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
Hii...
Use the following function to copy the data from one table to the archived table..
When someone deletes the current record, you must be having its ID... So you can use its ID in the query string..
So once someone deletes this record.. you can write the following code on the page (after the confirm delete page):
<?php
$id=$_GET['id'];
$sql="Select * from <tablename> where id=".$id;
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
//Call the function to archive the table
//Function definition is given below
archive_record(<tablename>,$row);
//Once you archive, delete the record from original table
$sql = "Delete from <tablename> where id=".$id;
mysql_query($sql);
function archive_record($archived_tablename,$row)
{
$sql = "insert into $archived_tablename values(";
$i=0;
while($i<(count($row)-1))
{
$sql.="'".$row[$i]."',";
}
$i=$i+1;
$sql.="'".$row[$i]."'";
$sql.=")";
mysql_query($sql);
return true;
}
?>
sikka_varun
Junior Poster in Training
94 posts since Dec 2008
Reputation Points: 11
Solved Threads: 12
Thank you all for your help. The addition of a field in each record I called "active" solved the problem. On the insert new record page, I added a hidden field that sets "active" to the value of "0" (zero). Then, on both the front-end (public) and back-end (edit) pages, which are dynamically created, I added to the database query a bit of code like this:
$query_rsTableName = "SELECT * FROM TableName WHERE active = '0' ;
I created another page on the back end where a logged in user can retrieve the archived records with a "SELECT * FROM TableName WHERE active = '1';
Of course, instead of deleting records along the way, that process is now an "update" that merely changes the value of active from "0" to "1." And, also of course, the user can change the value of an archived record back to "0" to make it active again.
Thanks again.
Hidden form fields are not hidden securely, and can be viewed and messed with
instead use php to set the variable on the create new record page,
or set the default value of the field in phpmydadmin
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376