0

here's my problem, I have written some code that update a table with ajax, after have written it with php:

  query = ""

  echo <table>

I need to put an input elements after the table generated which extract it with php, it should come something like that:

query = ""
row = mysql_fetch_array(query)

echo <div id="table">
     echo <table>
     echo </table>
     echo <input type=submit value=Extract as Excel or CSV>
echo </div>

The table is yet updated with an ajax function that run a file like getvalue.php?q=id passed" that change the value in the div making another query.

Well I need the input extract to work but I can't figure out how to pass the query through ajax or php, I can pass the array but it's not what I need

Panther
  • 3,124
  • 9
  • 25
  • 47

1 Answers1

1

Correct me if I'm wrong, but if I read you correctly, you want to send back to the server (to process it into a csv file) the content of an html array which has been modified client side.

One way to do it, would be to extract a json representation of the content of your array and send it back, with ajax, to the server where you'll be able to manipulate it as an array (using json_decode)

This thread should help you with the html table to json part : HTML Table to JSON

If you just want to generate a csv for the user to download, you can do it entirely on the client side, hence avoiding a roundtrip to the server.

You'll find several exemple online. Here are a few (I haven't tried any of them):

Community
  • 1
  • 1
lisa
  • 539
  • 2
  • 16