Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <form id="task-form">
  2. <div class="form-group">
  3. <input type="number" id="id" placeholder="codigo" class="form-control">
  4. </div>
  5. <div class="form-group">
  6. <input type="number" id="cantidad" placeholder="cantidad" class="form-control">
  7. </div>
  8. <button type="submit" class="btn btn-primary btn-block text-center">
  9. Agregar
  10. </button>
  11. </form>
  12.  
  13.  
  14. <div class="col-md-7">
  15. <div class="bg-white">
  16. <table class="table table-bordered table-sm">
  17. <thead>
  18. <tr>
  19. <td>NĀ°</td>
  20. <td>Codigo</td>
  21. <td>Producto</td>
  22. <td>Cantidad</td>
  23. <td>Precio</td>
  24. <td>Total</td>
  25. </tr>
  26. </thead>
  27. <tbody id="tasks"></tbody>
  28. </table>
  29. </div>
  30. </div>
  31.  
  32. include('conec.php');
  33.  
  34. $id = $_POST['id'];
  35.  
  36. $query = "SELECT * from productos WHERE id_prod=$id";
  37. $result = mysqli_query($con, $query);
  38.  
  39.  
  40.  
  41. if(!$result) {
  42. die('Query Failed'. mysqli_error($con));
  43. }
  44.  
  45. $json= array();
  46.  
  47. while($row = mysqli_fetch_array($result)) {
  48. $json[] = array(
  49. 'id' => $row['id_prod'],
  50. 'nombre' => $row['nombre_prod'],
  51. 'precio' => $row['precioV_prod'],
  52. 'cantidad' => $cantidad,
  53. 'total' => (($cantidad)*($row['precioV_prod']))
  54. );
  55. }
  56.  
  57. $jsonstring = json_encode($json);
  58. echo $jsonstring;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement