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

126
Views
pasar datos dinámicos a la solicitud ajax para recuperar datos mysql

Tengo datos de la base de datos mysql. Si estos datos vienen con identificaciones únicas individuales en un formato de tabla, cuando hago clic en una fila de tabla en particular, quiero publicar esa identificación a través de ajax y agregar el resultado en un div.

código para buscar y recuperar datos de mysql

 <?php require ('config/searchConfig.php'); $return = ''; if(isset($_POST["query"]) && !empty($_POST['query'])) { $search = mysqli_real_escape_string($conn, $_POST["query"]); $query = "SELECT * FROM products WHERE productName LIKE '%".$search."%' ORDER BY ID DESC " ; $result = mysqli_query($conn, $query); if(mysqli_num_rows($result) > 0) { $return .=' <div class="table-responsive"> <table class="table table-striped"> <tr> <th>Product Name</th> <th>Price</th> </tr>'; while($row1 = mysqli_fetch_array($result)) { $return .= ' <tr id="add-btn" style="height:5em;" > <td id="getID" value='.$row1["ID"].'>'.$row1["ID"].'</td> <td id="productName" value='.$row1["productName"].'>'.$row1["productName"].'</td> <td id="price" value='.$row1["price"].'>GHC '.$row1["price"].'.00</td> </tr> '; } '</table></div>'; echo $return; } else{ echo 'No product Found with that Name'; } } ?>

código para agregar el resultado en un div cuando hace clic en la fila de la tabla.

 <script type="text/javascript"> $(document).on('click', '#add-btn', function() { var getID = $('#getID').attr('value'); $.ajax({ //create an ajax request to display.php url:"getPrice.php", method:"GET", data:{getID:getID}, success: function(data){ $("#dynamicAddRemove").append(data); } }); }); </script>
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!