In this concluding article, explore the scripts which add andremove timesheet entries to the system, and get a crash course instatistics by using these entries to generate useful resource allocationand usage reports.
The opposite of "add.php" is "delete.php", which is designed to accept a list of record identifiers and delete the corresponding records from the "log" table. An array of these identifiers is passed to the script via the $lid array - take a look:
// delete.php - delete timesheet entries
// includes and checks
// open connection to database
$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to
// iterate through checkbox array, delete records
for ($x=0; $x<sizeof($lid); $x++)
$query = "DELETE FROM log WHERE lid = '$lid[$x]'";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());
// close connection
// redirect back
Here too, once the deletion has been accomplished, the user
is taken back to the originating instance of "view.php"