Re: db insert question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for all your help, ive got it working as i needed, my db query is built like this, works but probably not the best way of doing it:-



$sqlStart = "INSERT INTO `tester` (";
$sqlMiddle = ") VALUES (";
$sqlEnd = ")";

$keys = array();
$values = array();


		foreach($formData as $keyName => $keyValue){
		  array_push($keys, "`$keyName`");
		  array_push($values, "'$keyValue'");
		}
		
		
$keys = implode(",", $keys);
$values = implode(",", $values);


$query = "$sqlStart$keys$sqlMiddle$values$sqlEnd";
$result = mysql_query($query);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux