I have this list of "coupons" each with a unique "productid"
Now I am trying to convert the list into an array using:
$claimed = array($rowOrder['productid']);
My issue is when I try to use "count" and "array_sum" it outputs individual numbers:
$count_claimed = array(count($claimed));
echo array_sum($count_claimed);
Using the echo I get and output of: "1111111" What should I change to get a sum count of 7? (as displayed with the number of "coupons")
additional info:
The "coupons" are being outputted by this SELECT statement, $rowOrder is calling this.
public function SelectLst_ByUsrCustomerIDInfo($db, $usrcustomerid) {
$stmt = $db->prepare(
" SELECT o.orderid, o.productid, o.usrcustomerid, o.amount, o.amountrefunded, o.createddate, o.scheduleddate, o.useddate, o.expirationdate, p.photosrc
FROM `order` o LEFT JOIN `product` p ON o.productid = p.productid
WHERE usrcustomerid = :usrcustomerid"
);
$stmt->bindValue(':usrcustomerid', $usrcustomerid, PDO::PARAM_INT);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $rows;
}
This is called like this
$lstInfo = $mcOrder->SelectLst_ByUsrCustomerIDInfo($db, $usrcustomerid);
foreach($lstInfo as $rowOrder) {
if (isset($rowOrder['productid']) && ($rowOrder['expirationdate'] > date("Y-m-d H:i:s"))) {
$claimed = array($rowOrder['productid']);
$count_claimed = array(count($claimed));
echo array_sum($count_claimed);
}
}

$claimed = array($rowOrder['productid']);will also be an array of length one. You probably want to push it to an array instead of assign it to an array, then usecount()alone (array_sum()will sum all values of an array consisting of many numbers).SelectLst_ByUsrCustomerIDInfo? Show that code as well.