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

245
Views
How to get data from html-table via php

I have html-table and three buttons:

<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>

You can see there are no rows in it by default.

In javascript I add rows and cells by clicking the button "Add". Also I can delete them by clicking the button "Delete".

When I finish adding rows and cells I click the button "Save". And by clicking "Save" I want to save the information in txt-file, for example. I know how. As I am new in php, I am not an IT-guy, I do not want to work with MySQL, ajax, etc.

How is it possible to just take the information for html-table by php. In test.php I wrote:

<?php
print_r ($_POST);
?>

to check whether I get the information or not. So I do not.

If you ask yourself why someone do not want to work with mysql and want to save the information in txt-file I can answer: it is probably easier for me as there is not so much information I will work with and I will not have to learn how to work with MySQL.

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

0

In order to pass along the data to PHP the HTML your using must have items in the form with names. Here is how that could look for you.

index.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>

test.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!