How many times have your cursed PHP because you have to explicitly name each field and value when inserting and updating your database fields? So long as your form field names are named the same as your DB fields, this script will update, insert, and delete upon command. It's wonderfully commented, too!!!
PHP Example :
<?php
////////////////////////////////////////////////////////////
// Function Name: db_insert()
// Accepts: varchar table
// Returns: Success or mysql_error()
//
// Author: Andrew Deering
// Date: 12/09/04
//
// Purpose:
//
// This function takes all of the posted form elements
// and inserts them into $table.
///////////////////////////////////////////////////////////
function db_insert($table){
//$query = "INSERT INTO <table>(
$query = "INSERT INTO ".$table." (";
////////////////////////////////////////////////////////////
// Function Name: db_update()
// Accepts: varchar table, varchar pk, varchar pkval
// Returns: Success or mysql_error()
//
// Author: Andrew Deering
// Date: 12/10/04
//
// Purpose:
//
// This function takes all of the posted form elements
// and updates $table WHERE $pk = $pkval with new values.
///////////////////////////////////////////////////////////
function db_update($table, $pk, $pkval){
//$query = "UPDATE <table> SET
$query = "UPDATE ".$table." SET ";