On 5/2/07, Rahul S. Johari <[EMAIL PROTECTED]> 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.



Either gather all the data together first, and then do an insert, or do an
insert on the 1st part, then update the record with the remaining data with
a where clause (Use last_insert_id() to track a primary key, or pass some
unique identifier from the insert to the update query). Personally, I'd find
a way to gather all the data first and do it all with one insert.

David

Reply via email to