Form Method
Form Method
Form Method
<label for="Cantidad">Cantidad:</label>
</select>
<select name="Peso_Measure">
<option value="libras">Lbs</option>
<option value="kilos">K</option>
<option value="toneladas">T</option>
</select>
<label for="Peso">Peso:</label>
<br><br>
<label for="Origen">Origen:</label>
<input type="text" name="Origen" required><br><br>
<label for="Descripcion">Descripción:</label>
<label for="Categoria">Categoría:</label>
<option value="Alimentos">Alimentos</option>
<option value="Ropa">Ropa</option>
<option value="Tecnología">Tecnología</option>
<option value="Deporte">Deporte</option>
<option value="Juguetes">Juguetes</option>
</select><br><br>
<label for="Proveedor">Proveedor:</label>
<label for="Estado">Estado:</label>
<option value="Intermedio">Intermedio</option>
<option value="Malo">Malo</option>
</select><br><br>
</form>
<style>
.message {
margin-bottom: 15px;
padding: 10px;
background-color: #e0f7fa;
color: #00796b;
border-radius: 5px;
</style>
</body>
</html>
CODIGO DE GESTION
<?php
$host = "localhost";
$usuario = "root";
$password = "";
$baseDeDatos = "lya";
if ($conexion->connect_error) {
if (isset($_GET['eliminar'])) {
$id = $_GET['eliminar'];
$conexion->query($sql);
if (isset($_POST['editar'])) {
$id = $_POST['id'];
$cantidad = $_POST['cantidad'];
$origen = $_POST['origen'];
$peso = $_POST['peso'];
$descripcion = $_POST['descripcion'];
$precio_unitario = $_POST['precio_unitario'];
$categoria = $_POST['categoria'];
$proveedor = $_POST['proveedor'];
$estado = $_POST['estado'];
$sql = "UPDATE entradas SET
Cantidad='$cantidad',
Origen='$origen',
Peso='$peso',
Descripcion='$descripcion',
Precio_unitario='$precio_unitario',
Categoria='$categoria',
Proveedor='$proveedor',
Estado='$estado'
WHERE Id_Producto='$id'";
$conexion->query($sql);
$idProducto = "";
$categoria = "";
if (isset($_POST['buscar'])) {
$idProducto = $_POST['id_producto'];
$categoria = $_POST['categoria'];
if (!empty($idProducto)) {
} elseif (!empty($categoria)) {
}
$resultado = $conexion->query($sql);
$totalResultados = $resultado->num_rows;
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Gestión de Productos</title>
</head>
<body>
<h1>Gestión de Productos</h1>
</form>
<table border="1">
<tr>
<th>ID Producto</th>
<th>Cantidad</th>
<th>Origen</th>
<th>Peso</th>
<th>Descripción</th>
<th>Precio Unitario</th>
<th>Categoría</th>
<th>Proveedor</th>
<th>Estado</th>
<th>Acciones</th>
</tr>
$colorEstado = '';
switch ($row['Estado']) {
case 'Bueno':
$colorEstado = 'green';
break;
case 'Intermedio':
$colorEstado = 'yellow';
break;
case 'Malo':
$colorEstado = 'red';
break;
?>
<tr>
<!-- Celda de cantidad con fondo rojo si el valor es menor o igual a 100 -->
</td>
<!-- Celda de estado con color de fondo basado en el valor de estado -->
</td>
<td>
</td>
</tr>
<?php } ?>
<tr>
</tr>
</table>
<?php
$id = $_GET['editar'];
$editarSQL = "SELECT * FROM productos WHERE Id_Producto='$id'";
$resultadoEditar = $conexion->query($editarSQL);
$producto = $resultadoEditar->fetch_assoc();
?>
<h2>Editar Producto</h2>
<label>Cantidad:</label><br>
<label>Origen:</label><br>
<label>Peso:</label><br>
<label>Descripción:</label><br>
<label>Precio Unitario:</label><br>
<label>Categoría:</label><br>
<label>Proveedor:</label><br>
<input type="text" name="proveedor" value="<?php echo $producto['Proveedor']; ?
>"><br>
<label>Estado:</label><br>
</form>
</body>
</html>