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

248
Views
Cómo obtener datos de la tabla html a través de php

Tengo html-table y tres botones:

 <form action="test.php" method="post"> <table id="table"></table> <input type="button" id="add" value="Add"> <input type="button" id="delete" value="Delete"> <input type="submit" id="save" value="Save"> </form>

Puede ver que no hay filas en él de forma predeterminada.

En javascript, agrego filas y celdas haciendo clic en el botón "Agregar". También puedo eliminarlos haciendo clic en el botón "Eliminar".

Cuando termino de agregar filas y celdas, hago clic en el botón "Guardar". Y al hacer clic en "Guardar", quiero guardar la información en un archivo txt, por ejemplo. Se cómo. Como soy nuevo en php, no soy un tipo de TI, no quiero trabajar con MySQL, ajax, etc.

¿Cómo es posible simplemente tomar la información de html-table por php. En test.php escribí:

 <?php print_r ($_POST); ?>

para comprobar si obtengo la información o no. Así que no lo hago.

Si se pregunta por qué alguien no quiere trabajar con mysql y desea guardar la información en un archivo txt, puedo responder: probablemente sea más fácil para mí, ya que no hay tanta información con la que trabajaré y no tendré que hacerlo. aprender a trabajar con MySQL.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para pasar los datos a PHP, el HTML que esté utilizando debe tener elementos en el formulario con nombres . Así es como eso podría buscarte.

índice.html

 <form action="test.php" method="post"> <table id="table"> <input type="text" name="rows[1][item1]" value="123test"> <input type="text" name="rows[2][item1]" value="321test"> </table> <input type="button" id="add" value="Add"> <input type="button" id="delete" value="Delete"> <input type="submit" id="save" value="Save"> </form>

prueba.php

 <?php var_dump($_POST); /* output of $_POST above array (size=1) 'rows' => array (size=2) 1 => array (size=1) 'item1' => string '123test' (length=7) 2 => array (size=1) 'item1' => string '321test' (length=7) */
about 4 years ago · Juan Pablo Isaza Report
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!