Php > Database Related
Insert data into mysql table
Insert data into mysql table counter=[$counter] what=[$what]\n"; } return $what; }; function insertData($inputTable, $inputField, $inputValue) { $i = 1; $fieldList = ""; $valueList = ""; $fieldCount = 0; $fieldCount = count($inputField); foreach ($inputField as $v) { $fieldList = $fieldList . $v; $i++; if ($i <= $fieldCount) { $fieldList = $fieldList . ", "; }; }; # reset local vars $i = 1; reset($inputField); foreach ($inputValue as $v) { $v = fixQuotes($v); $valueList = $valueList . chr(39) . $v . chr(39); $i++; if ($i <= $fieldCount) { $valueList = $valueList . ", "; }; }; $query = "INSERT INTO " . $inputTable . " (" . $fieldList . ") VALUES (" . $valueList . ");"; print "
"; #print $query; $result = mysql_query($query); if (!$result) { print "
Insert failed, dammit.
\n"; } else { #print "
Inserted ok.
"; }; }; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage