Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Tengo problemas para actualizar mi base de datos desde AJAX

Tengo shoppingbasket.php que tiene un formulario HTML y está vinculado a incrementing.js Tengo botones más y menos que actualizan la cantidad del artículo en la cesta, sin embargo, tengo problemas para actualizar mi base de datos (en PHPMyAdmin) para que el La tabla 'cesta' se actualiza automáticamente cuando alguien usa los botones más o menos.

Cesta de la compra.php incluye:

 Print '<div id="list_item"> <img src="Images/' . $img . '"> <div id="rightside"> <a href="singlepage.php?subject=' . $product_id . '">' . $name . '</a><br> <p>' . $subtitle . '</p><br> <form id="quantity" method="POST" action=""> <div class="numbers-row"> <input type = "text" id="' . $product_id . '" value="' . $quantity . '"> </div> </form> </div> </div>';

Incrementing.js incluye:

 $(function() { $(".numbers-row").append('<div class="inc button">+</div><div class="dec button">-</div>'); $(".button").on("click", function() { var $button = $(this); var oldValue = $button.parent().find("input").val(); if ($button.text() == "+") { var quantity = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below zero if (oldValue > 0) { var quantity = parseFloat(oldValue) - 1; } else { quantity = 0; } } }); var pid = $button.attr("id"); $.ajax({ type: "POST", url: "basket2table.php", data: { pid : pid, quantity: quantity, }, success: function() { $button.parent().find("input").val(quantity); } }); });

Basket2table.php incluye:

 <?php include("dbconnect.php"); if(isset($_POST['quantity'])) { $quantity = $_POST['quantity']; } if(isset($_POST['pid'])){ $pid = $_POST['pid']; } $sql_query = "UPDATE Basket SET quantity='$quantity' WHERE product_ID='$pid' "; $result = $db-> query($sql_query); ?>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!