Currently have the following array which is dynamic (the user can have multiple singleocc / doubleocc results.
Array
(
[rateid] => Array
(
[0] => 51
[1] => 53
)
[singleocc] => Array
(
[0] => Array
(
[rate_monpr] => 89
[rate_tuespr] => 89
[rate_wedspr] => 87
[rate_thurspr] => 87
[rate_fripr] => 52
[rate_satpr] => 566
[rate_sunpr] => 947
)
[1] => Array
(
[rate_monpr] => 21421
[rate_tuespr] => 412
[rate_wedspr] => 4124
[rate_thurspr] => 1241
[rate_fripr] => 42
[rate_satpr] => 14
[rate_sunpr] => 141242
)
)
[counter1] => 2
[doubleocc] => Array
(
[0] => Array
(
[rate_monpp] => 474
[rate_tuespp] => 8
[rate_wedspp] => 68
[rate_thurspp] => 4
[rate_fripp] => 145
[rate_satpp] => 4
[rate_sunpp] => 13
)
[1] => Array
(
[rate_monpp] => 142
[rate_tuespp] => 24
[rate_wedspp] => 142
[rate_thurspp] => 21
[rate_fripp] => 41
[rate_satpp] => 12
[rate_sunpp] => 42422
)
)
[counter2] => 2
)
What I am looking to do is loop through the arrays and insert them into the database, havent done much with arrays from the insertion side of things, usually only reading out to the front end.
Any help is greatly appreciated! Thanks!
EDIT:
Here are the columns I am trying to insert to:
(rate_monpr
, rate_tuespr
, rate_wedspr
, rate_thurspr
, rate_fripr
, rate_satpr
, rate_sunpr
, rate_monpp
, rate_tuespp
, rate_wedspp
, rate_thurspp
, rate_frispp
, rate_satpp
, rate_sunpp
, session_id
, linked
, rateid
)
The session ID is set to the php session id and the linked column is a default 0 until I link the table to another in a later stage of the process.
I have tried various combinations of foreach loops and have just this second got the mon-sun rates in, just a bit confused as to how to get the rateid into it.
foreach ($sql_row as $keyn => $valuen) {
$sql .= $valuen;
echo $sql;
$con->query($sql);
$sql = "INSERT INTO rates_2_rates (rate_monpr,rate_tuespr,rate_wedspr,rate_thurspr,rate_fripr,rate_satpr,rate_sunpr) VALUES ";
}