1

I have a page with a java script that adds a row to a table. On the same page there is a PHP script that should read the table and add it to the database. How do I read the table using PHP ?

SergeyBukarev
  • 1,478
  • 1
  • 12
  • 19

3 Answers3

1

What you're thinking of will not directly work.

A Javascript script is executed on the client side only, whereas a PHP is executed on the server side only, and before the datas are sent to the client.

PHP can not directly read the table.

What you can do is use AJAX to send the data from the user's browser to a PHP script that'll use them.

You'll find more infos here.

Theox
  • 1,363
  • 9
  • 20
0

PHP is serverside programing, the PHP code serves data to the client - PHP can't read from the client.

If you add a row using javascript, PHP has no way of getting that info.

You'll need to use Ajax to solve your specific problem.

Patrick
  • 3,289
  • 2
  • 18
  • 31
0

You cannot "read the table" with PHP. You will have to send the data of the table to the server (and read it with PHP) using JavaScript or CGI.

A well-known technique to do this is called Ajax.

Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195