I have a dynamic html table( rows are added dynamically using java script) and I want to pass whole table to a php script as an array.Is there a way to insert the table data to an array?
I have tried using phpTableExtractor but it dosen't extract dynamically added rows.
I don't see any other reliable solution but creating a HTML form along with the table and have the user click a submit button to save the table. Then you can read all content from $_POST and store it in a database.
Another solution would be to use AJAX requests to store the table content every time the focus changes or something like that. Will make your page dependent on JavaScript though.
What if you fill a JS array at the same time you create the table?
You will use the html just for display but behind you have the data you send to php.
Related
I'm having problems with my work - I want to automatically insert a table when user registers. I've already finished the registration part but how can I show another user the users registered with table tag?
There are two ways to achieve this:
If you are using form submit and redirection than put the table in a foreach() loop with the data array coming from database table. Then when ever user comes on this page it takes all the newly added values and render the table.
Use jQuery Ajax to save the data and append new <tr> row into table body.
I want to implement an inventory table visible below. What I want to know is how to retrieve a table row data, for example when I click the "edit" link from the row of "Item One", I can retrieve it's Item ID "A00". Well, the rest will be up to me after I retrieved that row data. I just want to know first how to retrieve it.
Please be informed that I have already displayed the table shown using php, retrieving of table row data by clicking those <a> links is the only thing I need to know. Please give me a hint on how to do it, I really need it for our project. This is important to us, any help would be appreciated, thank you very much for your ample time!
Use jQuery Ajax and pass your ID as a parameter to the PHP file. Then your PHP file fetches the respective row from your database table.
Alternatively, you can just use jQuery/Javascript to load the content of the current row into the form and 'on update' you can update your database row with the new values. Ajax can also be used in this case so that the page doesn't refresh.
Try this:
Using jQuery ajax you can pass the ID of that record to php file.
Inside that file, You can retrieve the data of that row using ID you passed. For that, use SELECT query to get row data.
Then pass data to jQuery response to use it in the form to display.
Thanks
I need to save the data within these page elements into a database - they will be dynamically created by the user, but always in a similar format
The HTML appears:
<div><p>1</p>
<div><p>Broccoli</p></div>
<div><p>Carrot</p></div>
</div>
<div><p>2</p>
<div><p>Chicken</p></div>
<div><p>Beef</p></div>
<div><p>Lamb</p></div>
</div>
values needed from this:
"1:Broccoli", "1:Carrot", "2:Chicken", "2:Beef", "2:Lamb"
(happy to add classes/IDs to any divs to extract the required values)
What should happen:
On click of a save button, data is scraped into an array (via
Jquery?)
Array is sent to PHP file and inserted into the database
Any help on this would be great, thanks
you should save this data to the database as the user is creating it. not try to scrape your own page afterwards. This is going o save you a lot of time and make your script run faster.
Once you've done that, you can use serialize() to convert your array into a string that you can store in a database, and then turn the string back into an array with unserialize()
I am creating a website. On one of the pages there is a JavaScript form that asks for the usual information: Name, email etc and then I need to save it into a table using MYSQL and then I want to display the table using PHP on another page. I have no idea how to start saving the data into a table (when Submit is hit) and then displaying the table on another page. Any advice?
http://teamtutorials.com/web-development-tutorials/php-tutorials/inserting-data-into-a-mysql-database-using-php#.T5rIZLNWq9Q
the application simply is
dynamic page generate html code with some data within table cells by receiving parameters
i could get these pure data by jquery
but i find trouble sending it by ajax to another page(the basic page)
to display it in another format
You could try to serialize the table into a json and pass it to the next page where you could recreate the table based on the json. Just a quick idea