Array foreachloop
Posted: Sun Jan 23, 2011 6:26 pm
Ok this works but its only getting the latest item added
$database = new OrderTable();
$gamesList = $database->readtbl();
$database2 = new GamesTable();
foreach ($gamesList as $game) :
$view->checkOutList = $database2->checkoutGames($game->getItem());
endforeach;
Thats the code where something is going wrong. gamesList gets all the items from the OrderTable (I checked with a echo, all items get put in it) I then use the ID inside gamesList to match it with item ids in GamesTable. Its working, but only the 1 item is added, the latest one. I need it to get all the items from the GamesTable, that match the id in gamesList array
$database = new OrderTable();
$gamesList = $database->readtbl();
$database2 = new GamesTable();
foreach ($gamesList as $game) :
$view->checkOutList = $database2->checkoutGames($game->getItem());
endforeach;
Thats the code where something is going wrong. gamesList gets all the items from the OrderTable (I checked with a echo, all items get put in it) I then use the ID inside gamesList to match it with item ids in GamesTable. Its working, but only the 1 item is added, the latest one. I need it to get all the items from the GamesTable, that match the id in gamesList array