Re: INSERT Array Values into mySQL Table

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

 



On Wed, May 2, 2007 10:42 am, Rahul S. Johari wrote:
> 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:
>

//note added arguments!
>     function pr1($var, $var2, $var3) {
>             foreach ($var as $k => $v) {
>             echo ³$k => $v²;

echo "$var2[$k] $var3[$k]";

//DID YOU USE mysql_real_escape_string YET?!
$query = "insert into whatever (v1, v2, v3) ";
$query .= " values('$v', '$var2[$k]', '$var3[$k]') ";

Or maybe $v is an array itself?

//perhaps you want:
list($v1, $v2, $v3) = each($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²
>
>
>
>
>
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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