6
I have the following array()
Array
(
[camposdb] => Array
(
[51] => Array
(
[0] => cpf_cnpj
[1] => nome_razaosocial
[2] => cod_cliente
[3] => cod_contrato
[4] => mensagem
[5] => mensagem
[6] => mensagem
)
[60] => Array
(
[0] => celular
[1] => nome_razaosocial
[2] => nome_razaosocial
[3] => cod_contrato
[4] => mensagem
[5] => mensagem
[6] => telefone_r_1
)
)
)
In my form, I select the database records, and put the inputs in that way: camposdb[$row_fetch['id']][]
that bring me the result above.
What I need to do is this...
UPDATE tabela SET (cpf_cnpj, nome_razaosocial....) WHERE id = 51
.
The question is: How do I define that 51 and 60 are ids being that they are dynamic?
$id = $campodb[0][???]
My data comes from $_POST, in this case the name of the fields are: camposdb[<? echo $row_fetch['id'];?>][]
– Sr. André Baill
@Andrébaill I followed the example just above, and now I don’t understand how your data comes, so an issue in your question would help understand...
– novic
I edited my question, maybe you understand a little better :)
– Sr. André Baill
In this case, I can put $array = $_POST; ?:
– Sr. André Baill
@Andrébaill to get the keys that can be dynamic or not the two codes are there as an example of the array you passed. The function
array_keys
takes the keys that in case is 51 and 60 with these keys inside thearray
main I doarray['camposdb'][$key]
which are all the information of the selected id. In the example for the data variable will get all the information of each id.– novic
Yes you can. no problem @Andrébaill ...
– novic
Okay, it worked out, that’s exactly what I needed @Virgilionovic, thank you very much!
– Sr. André Baill