Calculating Discount Percentage of a given discounted price
Use this formula for calculating the discount percentage :
Discount%=(Original Price - Sale price)/Original price*100
Translating it into code, it should be something like :
$percent = (($rowx->Orgprice - $rowx->SalePrice)*100) /$rowx->Orgprice ;
selling price = actual price - (actual price * (discount / 100))
So for example if (actual price) = $15, (discount) = 5%
selling price = 15 - (15 * (5 / 100)) = $14.25
The correct formula is 1 - (sale price / original) * 100
, so:
$percent = 1 - ($rowx->SalePrice / $rowx->Orgprice) * 100;
$percent = 1 - (25 / 50) * 100 = 50