"; if($dvdId == -1) $error .= "Please select a \"DVD\"
"; if(($dateOut == null) || (strlen($dateOut) == 0)) $error .= "Please enter a \"Date Out\" Value
"; if(($dateDue == null) || (strlen($dateDue) == 0)) $error .= "Please enter a \"Date Due\" Value
"; if(strlen($error) == 0) { // Reformat dates so that they are compatible with the MySQL format if($dateOut != null) $dateOut = substr($dateOut, 6, 4)."-".substr($dateOut, 0, 2)."-".substr($dateOut, 3, 2); if($dateDue != null) $dateDue = substr($dateDue, 6, 4)."-".substr($dateDue, 0, 2)."-".substr($dateDue, 3, 2); if($dateIn != null) $dateIn = substr($dateIn, 6, 4)."-".substr($dateIn, 0, 2)."-".substr($dateIn, 3, 2); else $dateIn ="0000-00-00"; if(strcmp("save", $command) == 0) { // Run the update in update.php include "update.php"; } else { // Run the insert in insert.php include "insert.php"; } // Redirect the application to the listing page header("Location: index.php"); exit; } } else { // If it is a new record, initialize the variables to default values if(strcmp("add", $command) == 0) { $transactionId = 0; $orderId = 0; $dvdId = 0; $dateOut = date("m-d-Y", time()); $dateDue = date("m-d-Y", time() + 3*24*60*60); $dateIn = ""; } else { // If it is an existing record, read from database if($transactionId != null) { // Build query from transactionId value passed down from form $selectSql = "SELECT ". "OrderID, ". "DVDID, ". "DateOut, ". "DateDue, ". "DateIn ". "FROM Transactions ". "WHERE TransID = '$transactionId'"; // Execute query $result = mysql_query($selectSql, $link); if (!$result) die("Invalid query: " . mysql_error(). "
".$selectSql); // Populate the variables for display into the form if($row = mysql_fetch_array($result)) { $orderId = $row["OrderID"]; $dvdId = $row["DVDID"]; $dateOut = $row["DateOut"]; $dateDue = $row["DateDue"]; $dateIn = $row["DateIn"]; // Reformat the dates into a more readable form if($dateOut != null) $dateOut = substr($dateOut, 5, 2)."-".substr($dateOut, 8, 2)."-".substr($dateOut, 0, 4); else $dateOut = ""; if($dateDue != null) $dateDue = substr($dateDue, 5, 2)."-".substr($dateDue, 8, 2)."-".substr($dateDue, 0, 4); else $dateDue = ""; if($dateIn != "0000-00-00") $dateIn = substr($dateIn, 5, 2)."-".substr($dateIn, 8, 2)."-".substr($dateIn, 0, 4); else $dateIn = ""; } } } } ?> DVD - Listing

DVD Transaction  

0){?>
Order
DVD
Date Out
Date Due
Date In