I have a loop in PHP as follows:
$getDetails = mssql_query ("SELECT * FROM BasketItems
WHERE BasketID = '".$_GET['id']."' ");
while ($detailsrow = mssql_fetch_array($getDetails)) {
$TotalSetPrice = $detailsrow['FinalPrice'] * $detailsrow['Qty'];
echo $TotalSetPrice;
$numberofent = count($detailsrow['FinalPrice']);
echo "######NUMBER#####: $numberofent";
$TotalPrice = ?????;
######VARIOUS DATA##############
}
So ok i’m not an expert at PHP by any means, thats the first thing. FinalPrice is the price of an item in the DB that someone has selected. However the customer can have any number of quantity of those items.
So FinalPrice * Qty = TotalSetPrice
However the customer may also have different sets of items within the basket.
So I need to calculate TotalSetPrice * (Number of sets of items Within the DB)
SO I googled, and came up with count(), but if I just count($detailsrow) it returns 56 entries, this is the number of overall pieces of data if that makes sense. I just want to count the dumber of actual data sets. I tried counting finalprice but that just returns 1, which isn’t correct either.
Can anyone give me some guidence on how you are meant to count the number of entries in an array loop such as this. I hope that makes more sense than I feel it does.
SELECT FinalPrice, Qty,(FinalPrice * Qty) AS TotalSetPrice
Just use mysql, so that you no longer use with php which you will need to write a longer code