Forum Moderators: coopster
I have the following function:
function GetList($Value)
{
$order_items_List = Array();
$Database = new DatabaseConnection();
$query = "select * from order_items where (IOrderID = $Value)";
// echo $query;
$Database->Query($query);
for ($i=0; $i < $Database->Rows(); $i++)
{
$order_items = new order_items();
$order_items->Get($Database->Result($i,"IOrderID"));
$order_items_List[] = $order_items;
}
return $order_items_List;
}
The query is correct and returns two distinct records. The problem is when I try to display the results I get two instances of the first record and not both records.
Here's what I'm using to display
$items = new order_items();
$itemslist = $items->GetList(10);
foreach ($itemslist as $items)
{
echo "<tr>";
echo "<td class=\"list\" height=\"25\">".$items->ItemID."</td>";
echo "<td class=\"list\" height=\"25\">".$items->ISKU."</td>";
echo "<td class=\"list\" height=\"25\">".$items->IDescription."<br /></td>";
echo "<td class=\"list\" height=\"25\"> </td>";
echo "<td class=\"list\" align=\"right\" height=\"25\">".$items->IPrice."</td>";
echo "<td class=\"list\" align=\"right\" height=\"25\">".$items->IPriceExtended."</td>";
echo "</tr>";
}
Can anyone see where I'm going wrong?
i have a little function in my global includes file which looks like this:
function aDump($array = array()){
echo '<pre>';
print_r($array);
exit;
}
you then call aDump($itemslist); just before you loop through the list and see what it returns - it will show you exactly how the array is structured, which nearly always helps.
if you are still stuck you could post the array structure here.
good luck