Array foreachloop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rosaka
Forum Newbie
Posts: 13
Joined: Mon Jan 10, 2011 2:00 pm

Array foreachloop

Post by Rosaka »

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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Array foreachloop

Post by requinix »

Then make ->checkOutList be an array. Right now it's just one value and inside your loop you keep overwriting the previous.
Post Reply