CRUD (Create, Retrieve, Update, and Delete) Records in a Database Table
- (Create) You may create a record by providing data and clicking the Add Record button.
- (Retrieve) You may retrieve a record by selecting the record (radio button) and clicking the Select Record button.
- (Update) You may update data by providing data and clicking the Save Record button.
- (Delete) You may delete a record by selecting the record (radio button) and clicking the Delete Record button.
// The following two functions should be in your code // -- OR -- be in the includes directory under "functions.php" // AND include that file in this script. // ================= functions ================= //-------------- show db errors -------------- // this function reports mysql errors with line number and script name function report($query, $line, $file) { echo($query . '
' . $line . '
' . $file . '
'); } //-------------- clean data for input into db -------------- // this function cleans all text for inserting into db // in other words, this function returns SQL injection-proof strings function cleanForDB($con, $str) { $str = stripslashes($str); $str = trim($str); $str = mysqli_real_escape_string($con, $str); return $str; }