<?php
session_start();
$servername = "localhost";
$username = "itladevprubycom_enma";
$password = "53gNpj4t.xDc";
$database = "itladevprubycom_enma1";

$conexion = new mysqli($servername, $username, $password, $database);

$query = $conexion->prepare("SELECT * FROM produc");
$query->execute();
$data = $query->get_result();


$id = $_SESSION["id"];

$nombre = @$_POST["nombre"];
$precio = @$_POST["precio"];
$descripcion = @$_POST["descripcion"];
$img = @$_POST["img"];



if ($_SERVER["REQUEST_METHOD"] === "POST") {
    if (isset($_POST["tipo"])) {
        $id = $_POST["tipo"];
        header("Location: edtienda1.php?id=".$id);
        exit();
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>agregar</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/css/uikit.min.css" />
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/js/uikit.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/js/uikit-icons.min.js"></script>
</head>
<body>
    <?php include "navbar.php";?>
            <div class="uk-card uk-card-body">
                <div class="uk-container">
                    <h2 class="uk-margin-large-top uk-text-center">Editar producto</h2>
                    <div class="uk-margin">
                        <form action="" method="post" enctype="multipart/form-data">
                            <div class="uk-form-controls">
                                <select class="uk-select uk-form-medium" name="tipo" id="form-stacked-select">
                                    <?php foreach($data as $value): ?>
                                        <option value="<?php echo $value['id']; ?>"><?php echo $value['producto']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="uk-margin uk-flex uk-flex-center uk-margin-small">
                                <button type="submit" class="uk-button uk-button-primary">Editar</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
    </div>
<div class="uk-container uk-flex uk-flex-center uk-margin-large-top">
    <a href="index.php" class="uk-button uk-button-default">Volver al inicio</a>
</div>
      
</body>
</html>

