I have been very busy with work lately and I had put my blogging career on hold, I am back now.. For this article I will try to be very precise two simple steps. STEP ONE Have a similar table as the table you are listening in for delete actions. On your new backup table you might want to have more fields like the delete_user, the computer_name where this was done and the time_stamp. You can easily create the backup table by copying the existing table then adding the extra columns. There are many ways to do this so i will let you decide on which one you prefer but I would normally quickly do it as follows; Run the following sql Create table mytablename_after_delete as select * from mytable; --then empty the table TRUNCATE TABLE mytablename_after_delete; --the add your extra columns using alter command alter table mytablename_after_delete add sysdate timestamp; --you can make it varchar if need be alter table mytablename_after_delete add deleted_by varchar(30); --a...
MySQLi and PDO are object oriented and support Prepared Statements (also support Transactions, Stored Procedures and more). Prepared Statements are very important for web application security, as they protect from SQL injection. Using Prepared Statements you do not have to escape strings before insert them in Database. Moreover, PDO offers support for many databases (not only MySQL). Establish a database connection $DBServer = 'localhost'; // or an IP address $DBUser = 'root'; $DBPass = 'your password'; $DBName = 'dbname'; $conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName); // check connection if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } //select rows $sql='SELECT * FROM users'; $rs=$conn->query($sql); $rows_returned = $rs->num_rows; echo $rows_returned; //returns number of rows //loop throu...