I have an array: $product_counts = array_count_values($product_array);
The keys for this array are merchant ID's and the values are integers (product counts). So if I was to write the following code:
foreach($product_counts as $key => $value){
echo "key: $key";
echo "value: $value";
}
I would get the following (which is what I want):
key: 26816928 value: 13
key: 26816931 value: 2 ...
X the amount of indexes in the array.
However if I was to write the following code:
foreach($product_counts as $key => $value){
mysql_query("INSERT INTO merchantinfo(ProductCount) VALUES $value WHERE MerchantID = $key");
}
The values of the $value variable don't go into the field where MerchantID = $key....instead the tuples just default to null, which is what I've set them to do. I believe this could be a case of needing to type cast the variable as integers .... but I'm in general quite lost with this.
Thanks in advance