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

94
Views
El botón para eliminar la fila de la tabla no se agrega a la tabla html

Estoy tratando de agregar un botón para eliminar la fila de la tabla cuando se hace clic. Esto debe colocarse junto a los datos que se emiten desde la base de datos MySQL. Por alguna razón, el botón no se emite, a continuación se muestra el código de mi tabla:

 <table> <thead> <tr> <th>Name</th> <th>Email</th> <th>Subject</th> <th>Message</th> <th>Have you replied?</th> </tr> </thead> <?php //makes a connection to the database $conn = mysqli_connect("localhost", "root", "", "messages"); if ($conn->connect_error) { die("Connection Failed:" . $conn->connect_error); } $sql = "SELECT * FROM tbl_messages"; $result = $conn->query($sql); if ($result->num_rows > 0) { //fills the table with the content in the database while ($row = $result->fetch_assoc()) { echo '<tr><td>' . $row["name"] . '</td><td>' . $row["email"] . '</td><td>' . $row["subject"] . '</td><td>' . $row["message"] . '</td><td><button id="replied" onclick="DeleteRow()"></button>' . '</td></tr>'; } echo "</table"; } else { echo "0 result"; } $conn->close(); ?> </table>

Y este es el código javascript para eliminar la fila de la tabla:

 <script> function DeleteRow() { var td = event.target.parentNode; var tr = td.parentNode; // the row to be removed tr.parentNode.removeChild(tr); } </script>

Imagen de la fila de mi tabla El espacio en blanco debajo del encabezado de la tabla "¿Ha respondido?" es donde debería estar el botón, pero no está allí

Todavía estoy aprendiendo PHP, por lo que cualquier respuesta sobre cómo puedo solucionar esto sería muy útil, por favor.

about 4 years ago · Santiago Trujillo
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!