So here I have a table of Products which contains ID
, Name
, Type
& Price
Now I'm running a function to give me the minimal price of specific product types.
The datatype of Price
is Price int(5,2)
function MinPrice($connection) {
echo "Minimum price: <br>";
$sql = "SELECT Type, min(Price)
FROM Products
GROUP BY Type;";
$result = mysqli_query($connection,$sql);
while ($row = mysqli_fetch_assoc($result)) {
//Printing the result
echo $row['Type'].' || '.$row['Price'].'<br>';
}
}
The code works but not properly. I get the names of the product types but for the price, it gives me an error.
Undefined index: Price
Can anyone please help me out with this?