Update:
Never mind, I finally figured it out. I was referencing the function Get() in the GetList() function and Get() was not searching by ItemID.
I have posted this problem on several PHP topic forums and have been working on it for several days and I cannot get it to work properly. You're my last hope.
I have the following function written in PHP
PHP:
-
-
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;
-
}
There are two records in the database. They each have a unique ItemID but the same IOrderID. When I try to display the results of the query in the above function I get two instances of the first record and not one instance of both records.
If I echo the query in MySQL I return both records as expected.
SQL:
-
SELECT * FROM order_items WHERE (IOrderID = '10')
Here is what I'm using to display the results
PHP:
-
-
$items = new order_items();
-
$itemslist = $items->GetList(10);
-
foreach ($itemslist as $items)
-
{
-
-
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>";
-
-
}
If I add the following to display the database results within the function
PHP:
-
-
echo $Database->
Result($i,
"IOrderID").
"<p>";
-
echo $Database->
Result($i,
"ItemID").
"<p>";
-
The results of the echo are the two records as expected.
I can't figure out why my code above won't return both records. Any ideas?