<?php
if (isset($_POST['id'])) {
    $idProducto = $_POST['id'];

    // Conexión a la base de datos
    $conexion = new mysqli("localhost", "root", "S1stemas", "eficrmp");
    //$conexion = new mysqli("localhost", "agtechsr_user", "Alefortress8.", "agtechsr_eficrm");

    if ($conexion->connect_error) {
        die("Conexión fallida: " . $conexion->connect_error);
    }

    $sql = "select q_f as precio from registration where id=(select max(id) from registration where miter_id =?)";
    $stmt = $conexion->prepare($sql);
    $stmt->bind_param("i", $idProducto);
    $stmt->execute();
    $stmt->bind_result($precio);
    $stmt->fetch();

    echo $precio;

    $stmt->close();
    $conexion->close();
}
