Re: 'Code Snippets' you couldn't live without
| From: | Alex Hogan | Date: | Wed, 03 Nov 2004 21:03:35 +0000 |
| Subject: | Re: 'Code Snippets' you couldn't live without | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201086@lists.php.net to get a copy of this message | ||
> snippets they couldn't live without when working on a PHP project. IE, the
> kind of re-usable bits and pieces that make your life a lot easier.
I hate always having to write queries for inserting and updating a db.
With this I can just name the form objects the same names as the
table fields and I'm done.
function insert($table, $fld, $val){
$query = "INSERT INTO $table (%s) VALUES (%s)";
$query = sprintf($query, implode(",", $fld), implode(",", $val));
$result = mssql_query($query) or die;
}
alex hogan