I have table item like this:
id color stock
1 red,green,yellow 10,20,30
and i grab an item with red color 5 and green 2 and put on table x like this :
id id_product color qty
1 1 red 5
1 1 green 2
what i want to achieve is to update table item become like this :
id color stock
1 red,green,yellow 5,18,30
what i do is :
$colors = $resultset['color'];
$color = explode(",",$result['color']);
$stock = explode(",",$result['stock']);
$flag = array_search($colors,$color);
$stock[$flag] = $stock[$flag] - $resultset['qty'];
from a code that i write above, when i echo $stock[$flag] it will return 5 and 18, but how can i implode that to become 5,18,30?
My problem is, i have 2 item in table x that have a same id_product but difference color, so when i do some looping and i do implode it give a result like this : 5,20,30 10,18,30. So, when i update to the table item, it just change like this :
id color stock
1 red,green,yellow 10,18,30
I just need some suggestion or help to figure out how can i implode that stock to become : 5,18,30. I will appreciate for the answer and suggestion..thx