Hi all,
I apologize ahead of time, but I still seem to struggle with multi-dimensional arrays.
I have 2 arrays, a products array, and a class array.
The products array is:
products [1] = 1258
products [6] = 1201
...and the class array (which are the classes related to the above products).
class [1][1] = 1
class [1][2] = 2
class [1][3] = 3
class [6][4] = 5
class [6][5] = 5
What I am trying to do is loop thru and get the product, then insert the class(es) related to each one.
I think I need to do something like (which I haven't got to work correctly)
foreach( $_SESSION['products'] as $productId => $productkey ) {
foreach( $_SESSION['class'] as $classId as $classkey) {
$sql = "INSERT INTO table (productkey, classkey) VALUES ($productkey, $classkey)";
}
}
storing them like...
Id --- productkey --- classkey
1 --------- 1 ------------ 1
2 --------- 1 ------------ 2
3 --------- 1 ------------ 3
4 --------- 6 ------------ 4
5 --------- 6 ------------ 5
Am I close with this, or am I way off base with this approach?
Thanks in advance,
d.