Personally, I'm having a hard time on my Back-end.
In a form I am sending data with dynamic data using for example name="qtd[]"
.
As far as beauty, in my PHP, I'm getting for example 2 lines of information, each column contains qtd, item, value, and value t (Being value = unit value, and by js I do the calculation that generates the total value in valort ), the array looks like this:
array (size=4)
'qtd' =>
array (size=2)
0 => string '2' (length=1)
1 => string '2' (length=1)
'item' =>
array (size=2)
0 => string 'item1' (length=5)
1 => string 'item2' (length=5)
'valoru' =>
array (size=2)
0 => string '2' (length=1)
1 => string '3' (length=1)
'valort' =>
array (size=2)
0 => string '4' (length=1)
1 => string '6' (length=1)
I imagined. Well now, I drag a foreach
and for each result I insert into the database, I saw that it did not work, I went to give var_dump
and it was returning like this:
array (size=2)
0 => string '2' (length=1)
1 => string '2' (length=1)
array (size=2)
0 => string 'item1' (length=5)
1 => string 'item2' (length=5)
array (size=2)
0 => string '2' (length=1)
1 => string '3' (length=1)
array (size=2)
0 => string '4' (length=1)
1 => string '6' (length=1)
In the end, instead of bringing the result by line, it is bringing arrays per column. Am I wrong when using Foreach? By the factor of dynamically creating the table, there is no way for me to know how many results I will receive. I already have a PHP pro class that allows me to write to array form, where I use the index as the table name in Mysql and the values as the value itself, in the end to execute I would just do this command:
$cadastra = new Create;
$cadastra->ExeCreate("item_orcamento", $array);
the var_dump of this would look something like:
public 'queryString' => string 'INSERT INTO item_orcamento (qtd, item, valoru, valort) VALUES (:qtd, :item, :valoru, :valort)
But this result completely broke my logic heheh. Should I recreate the arrays to send to the Database, or can my HTML be messing me up?
Thank you very much. Strong hug