I have a problem is I no have idea to start. Can give me some advices?
Now, I have a table data is from database. In the table I can edit the data, when I edit data, now I want to know when I change it the data, by who, and why I change it. So, I want to store this to a table in database.
I already create a table is called History inside have 3 column: Date-of-change, Change-Person, Change-Remarks.
How should I do? ???
If you no understand my question can give me comments.
on your edit page right after your update code have an insert code to insert into your history table, the date of change get be taken from the current time using a date/time function the user can be taken depending how your system is setup from a session/cookie of the logged in user, the remarks would either be set or a comment box for the user to fill in.
Yup. thanks…
I will try it. I think I know how to do.
I found this
However I don’t know how to write the coding.
Who can help?
mmm… Or can using trigger?? How to use?
here’s a way I would do it
create a log table:
CREATE TABLE IF NOT EXISTS `log` (
`logID` int(11) NOT NULL auto_increment,
`logTitle` varchar(255) NOT NULL,
`logDate` date NOT NULL,
`logTime` time NOT NULL,
`memberID` int(11) NOT NULL,
`logLink` varchar(255) NOT NULL,
PRIMARY KEY (`logID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Then create a function to insert data to the table place this inside your functions/global include file/s then you can use it in different places as needed
[php]
function addlog($logTitle,$memberID,$logLink=NULL){
$date = date('Y-m-d'); //get date
$time = date('G:i:s'); //get time
//secure data
$logTitle = strip_tags(mysql_real_escape_string($logTitle));
$memberID = strip_tags(mysql_real_escape_string(($memberID));
$logLink = strip_tags(mysql_real_escape_string(($logLink)); //optional
mysql_query("INSERT INTO log (logTitle,logDate,logTime,memberID,logLink)VALUES('$logTitle','$date','$time','$memberID','$logLink')");
}
[/php]
the function expects a title, the user id and optionally you can pass a link to the action
to use the function just call the function with the values:
[php] addlog(“your custom title”,$_SESSION[‘user_id’],“link-to-action”);[/php]
if you don’t want to use the link in the function then omit it:
[php] addlog(“your custom title”,$_SESSION[‘user_id’]);[/php]
Thank you daveismyname and others who give me advices.
It works thanks…