2

How to insert the datas from a <table> rows into the database without any <input> ?

In CodeIgniter, I have a function where I can generate random users, which are inserted into the <table>...</table> using an AJAX method by clicking on a $('#btnGenerate');

It fills out an empty table with the new table rows (<tr>). Here how it looks like:
Random user generator

Now when I want to save these new rows into the database, I don't know how to proceed. As far as I know, I need to have an array which will be then posted into the form's action: members/form_random for example with the $this->input->post('someInputName');?>. How can I do that if I don't use any <input> tags inside the table ?

Any advice for solution ?

1 Answer 1

3

When you generate the random users, make sure you store each row in an object array like

var arr = [
    {username:'abc',email:'[email protected]'},
    {username:'def',email:'[email protected]'},
     .
     .
];

And the trigger an onClick event from the Apply,Save Button to an AJAX function and send the array as JSON data to the controller that saves the data.

I think this will sort out your problem..

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your tip, i managed to work it out by using your tip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.