Hi I have created a simple foreach loop which is looping through an array and inserting the data into my db table. The problem I am having is it is only inserting 130 rows into my database even though the array contains 196.
Here is my code:
foreach ($currencyArray as $currency) {
if (count($currency) > 1) {
$currency_table = $db->prepare('
INSERT INTO currency_name (symbol, name, btc_value)
VALUES (:name, :symbol, :btc_value)
');
$currency_table->bindParam(':name', $currency[0]);
$currency_table->bindParam(':symbol', $currency[1]);
$currency_table->bindParam(':btc_value', $currency[2]);
$currency_table->execute();
}
}
I have made sure it isnt the if statement causing the problem. I added a count to inside the if statement and this count 197 records which is the amount of rows I am expecting in my db table, but it is only storing 130 rows?
If you also believe there is a faster way of inserting the array into the db table please feel free to share :)