RE: INSERT Array Values into mySQL Table

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

 



Rahul S. Johari wrote:
> Ave,
> 
> Here¹s the thing, I¹ve got an Array which has it¹s own set of
> Keys => Values. I¹m using foreach() to read the Keys => Values like
> this: 
> 
>     function pr1($var) {
>             foreach ($var as $k => $v) {
>             echo ³$k => $v²;
>             }
> 
> I need to INSERT the Values from this array into a  mySQL
> table. The problem is, There is other data that is going into
> the same row of that mySQL Table as well.
> 
> So I have to basically insert 3 fields and then the rest of
> values I have to insert using this Array. In other words, this is
> what I have to do: 
> 
> INSERT into table  (f1, f2, f3, f4, f5) VALUES (Œ$1¹, Œ$2¹,
> Œ$3¹, //and the rest of the values from from the $v Values from that
> Array $var..... 
> 
> I¹m not able to formulate a code to do this. Any help would be really
> appreciated. 
> 
> Thanks.
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Rahul Sitaram Johari
> CEO, Twenty Four Seventy Nine Inc.
> 
> W: http://www.rahulsjohari.com
> E: sleepwalker@xxxxxxxxxxxxxxxx
> 
> ³I morti non sono piu soli ... The dead are no longer lonely²


$sql = "INSERT INTO table (f1, f2, f3, ". implode(",", array_keys($pr1)) .")
	  VALUES ('abc', '123', '456', ". implode(",", array_values($pr1))
.")";

HTH,

Brad

-- 
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