I am doing my project to graduate, it is a web admin of works and I am looking for how to insert in the table WORKS the materials with the quantities (obras_cant)
and the tools with their quantities (herra_cant)
, example: Gray paint-15 Gal, sand m2, emery 2 Unds. In this case "gray paint" I bring from the table materiales
, like "emery" of the table herramientas
of to then show the works in lists with their materials and tools in pdf to be checked at the time of being delivered. a teacher who was better to do it by placing the field LONGTEXT and insert everything with JSON to save the id
of each tool or material with their quantities respectively. but I have no idea how to do it. so far I am showing the data consult to select with checkbox ......
<?php include_once 'templates/header-internas.php';
require_once('funciones/bd_conexion.php');
?>
<section class="seccion contenedor">
<h2>Agregar Obra</h2>
<form action="validar_obras.php" class="login" method="POST" id="obras">
<div class="campo">
<label for="obra">Nombre: </label>
<input type="text" name="obra" id="obra" placeholder="Introducir obra">
</div>
<div class="campo">
<label for="compra">Numero de Orden compra: </label>
<input type="text" name="compra" id="compra" placeholder="Introducir">
</div>
<div class="campo">
<label for="user">Supervisor a Cargo:</label>
<?php
try {
$sql = "SELECT * FROM usuarios WHERE status_id = 3 ";
$res_user = $conn->query($sql);
echo "<select name='user'>";
while ($user = $res_user->fetch_assoc()) { ?>
<option value="<?php echo $user['id_user'] ?> ">
<?php echo $user['nombre_user'] . " " . $user['apellido_user']; ?>
</option>
<?php }
echo "</select>";
} catch (Exception $error) {
echo "Error:" . $error->getMessage();
}
?>
</div>
<div class="campo clearfix">
<label for="client">Cliente </label>
<?php
try {
$sql = "SELECT * FROM clientes ";
$res_client = $conn->query($sql);
echo "<select name='client'>";
while ($client = $res_client->fetch_assoc()) { ?>
<option value="<?php echo $client['id'] ?> ">
<?php echo $client['nom_cliente'] . " " . $client['planta']; ?>
</option>
<?php }
echo "</select>";
} catch (Exception $error) {
echo "Error:" . $error->getMessage();
}
?>
</div>
<div class="campo clearfix">
<label for="herram">Selecionar herramientas:</label><br/>
<?php
try {
$sql = "SELECT * FROM herramienta ";
$res_herram = $conn->query($sql);
while ($herram = $res_herram->fetch_assoc()) {
echo '<input type="checkbox" name="herram[]" value=' . $herram['id_herra'] . '> ' . $herram['nom_herra'] . " " ;
echo '<input type="number" min="0" max="5" id="cant_herram" size="1" name="herram_cant" placeholder="0">' . '<br/>';
}
} catch (Exception $error) {
echo "Error:" . $error->getMessage();
}
?>
</div>
<div class="campo desplegable clearfix">
<label for="mater">Selecionar materiales:</label><br/>
<?php
try {
$sql = "SELECT * FROM materiales ";
$res_mater = $conn->query($sql);
while ($mater = $res_mater->fetch_assoc()) {
echo '<label><input type="checkbox" name="mater[]" value=' . $mater['id_mat'] . '> ' . $mater['nom_mat'] . " " ;
echo '<input type="number" min="0" max="50" id="cant_mat" size="1" name="mat_cant[]" placeholder="0">' . '<br/>';
}
} catch (Exception $error) {
echo "Error:" . $error->getMessage();
}
?>
</div>
<div class="campo">
<input type="submit" id="agregar" name="submit" class="button" value="Agregar">
</div>
</form>