query in loop using $array[$index]

wxdqz

New Member
Hi all -

Hope I'm explaining this clearly enough.

Is there anything wrong with this query?

$insertProdIdStmt = "UPDATE customer_product SET product_id = $productid[$index] where customer_id = $customerid";

Specifically, the problem is with the '$productid[$index]' segment. MySQL has a problem reading the value of the array at the position specified by each index on passes through the loop.

Yet if I run the query specifying a number ie. $productid[0] representing an index of the array the query works. Although only repeating the same query for the number of times through the loop rather than incrementing each time through to save a value from each different position in the array.

Any help/advice would be appreciated. I'm stymied by this.

Kris
 
Back
Top