i have a database with a table that has 10 items and all of these items have amounts(item_one, item_one_amount). So that's 20 rows in the table.
What i want to do is bind these 2 things in php, the item id with the amount.
Not sure how to go around my problem. Is a double foreach a good idea?
My db structure could also be a problem? My idea is: i have a 10 different bundles. Each of them has different items with different amounts of said items in there. The item id_s i get from another table that has all the information about the item
My db:
FirstItem, SecondItem, ThirdItem, FourthItem, FifthItem,
SixthItem, SeventhItem, EighthItem, NinthItem, TenthItem,
FirstItemID, SecondItemID, ThirdItemID, FourthItemID, FifthItemID,
SixthItemID, SeventhItemID, EighthItemID, NinthItemID, TenthItemID,
first_item_amount, second_item_amount, third_item_amount, fourth_item_amount,
fifth_item_amount, sixth_item_amount, seventh_item_amount, eighth_item_amount, ninth_item_amount, tenth_item_amount
FROM Bundles
My php attempt:
foreach ($all_ids as &$item_id) {
if ($item_id == 0){
break;
}
foreach ($all_item_amounts as &$item_amount) {
//do something
if ($item_amount == 0) {
break;
}
}
}
For some reason i'm stuck in the loop.