Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id="task-form">
- <div class="form-group">
- <input type="number" id="id" placeholder="codigo" class="form-control">
- </div>
- <div class="form-group">
- <input type="number" id="cantidad" placeholder="cantidad" class="form-control">
- </div>
- <button type="submit" class="btn btn-primary btn-block text-center">
- Agregar
- </button>
- </form>
- <div class="col-md-7">
- <div class="bg-white">
- <table class="table table-bordered table-sm">
- <thead>
- <tr>
- <td>NĀ°</td>
- <td>Codigo</td>
- <td>Producto</td>
- <td>Cantidad</td>
- <td>Precio</td>
- <td>Total</td>
- </tr>
- </thead>
- <tbody id="tasks"></tbody>
- </table>
- </div>
- </div>
- include('conec.php');
- $id = $_POST['id'];
- $query = "SELECT * from productos WHERE id_prod=$id";
- $result = mysqli_query($con, $query);
- if(!$result) {
- die('Query Failed'. mysqli_error($con));
- }
- $json= array();
- while($row = mysqli_fetch_array($result)) {
- $json[] = array(
- 'id' => $row['id_prod'],
- 'nombre' => $row['nombre_prod'],
- 'precio' => $row['precioV_prod'],
- 'cantidad' => $cantidad,
- 'total' => (($cantidad)*($row['precioV_prod']))
- );
- }
- $jsonstring = json_encode($json);
- echo $jsonstring;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement