I don’t think I understand what you are doing. Can you explain more precisely?
Hi i have made a screenshot for explain my situation.
image
With add student button i append with jquery any row in my table, but when i update my post wordpress save only the first student.
Thanks!
OK. What is the code that creates those rows and what is the code you are using to insert? Please use the pastebin.
pastebin
Sorry for bad code, im not a good coder!
Its hard to say without playing with it but it looks like you are telling the script to parse only the first student– foreach ($this->meta_box_students_fields[0] as $field) { // save each option
Why have you restricted that to array index ‘0’ only?
if i put foreach ($this->meta_box_students_fields[] as $field) { // save each option, i have this error
Fatal error: Cannot use [] for reading…
And if i use foreach ($this->meta_box_students_fields as $field) { // save each option, i dont see any changes.
Anyway im not able to display any saved data in this table, then i dont know what was saved!
I thought i need a loop into my table…
Thx again!
You don’t want $this->meta_box_students_fields[], just $this->meta_box_students_fields.
You are saving to the $wpdb->postmeta table. Just take a look at the table via PhpMyAdmin. Hopefully you have that available.
OK.
How can i display this saved data?
I meant inside at metabox
Don’t get ahead of yourself. The first step is getting things to insert into the db correctly.
I know you are going to want to display the data in your metabox somewhere but its going to be hard to find and debug the problem if you don’t know what, if anything, is even in the DB. If you don’t know what is being inserted, when you try to display the data and have a problem, you won’t know if the problem is with the insert or with the display code. Therefore, watch the DB using some other tool like PhpMyAdmin so that you know what is going on there.
well, i see db, wordpress put data into db correctly, but only the first values.
If i try to add another values, wordpress save only the first line, then only the first student.
Did you make the change I suggested?
Put print_r($this->meta_box_students_fields); on the line right before foreach ($this->meta_box_students_fields... and post that for me.
if i put this on the line right before foreach ($this->meta_box_students_fields…i dont see nothing!
Try var_dump($this->meta_box_students_fields); instead.