connect_error) { die("Connection failed: " . $conn->connect_error); } // Function to fetch the gold rates from the database function getGoldRates($conn) { $rates = [ '22k' => 0, '24k' => 0 ]; // Query the database for the gold rates $sql = "SELECT karat, price FROM gold_rates"; $result = $conn->query($sql); if ($result->num_rows > 0) { // Fetch rates from the database while ($row = $result->fetch_assoc()) { if ($row['karat'] == '22') { $rates['22k'] = $row['price']; } if ($row['karat'] == '24') { $rates['24k'] = $row['price']; } } } return $rates; } // Get the rates from the database $goldRates = getGoldRates($conn); $conn->close(); ?> Gold Rate Calculator

Gold Rate Calculator

Bangalore Today's Rates

22K Gold
/g
91.6% Pure

Rates updated: | Source: Database