-1
I have a database with dynamic columns that can appear one time, another time not... can also be added more columns or even extracted the ones that already exist.
I made a code that allows me to capture these columns in my database in real time and now I need to make these columns appear in another part of the code:
<?php
require("setup_do_banco.php");
$colunas = $pdo->prepare("SHOW COLUMNS FROM imovel");
$colunas->execute();
###### Aqui tenho todos as colunas do meu banco de dados
while ( $coluna = $colunas->fetch() ) {
$coluna = $coluna["Field"]; echo "$coluna <br />";
}
$array = array (
'key' => '8b0dc65f996f98fd178a9defd0efa077',
'module' => 'imoveis',
'method' => 'busca_imoveis',
'field' => array (
////////////////////////////////
# <------------
////////////////////////////////
)
);
$client = new SoapClient(null, array (
'uri' => 'http://soap.imo.bi/',
'location' =>
'http://soap.imo.bi/soap.dll',
'trace' => 'trace'
)
);
$res = $client->get($array);
echo "<pre>"; print_r($res); echo "</pre>";
?>
As you can see, through a loop I recovered all the columns from my database and now I need to plant them inside the place that is arrow each comma field at the end and line break. I tried to put the loop inside the array but it didn’t work.
How am I going to put the columns of my bench there in place of the arrow?
Why not declare this array before while, and while putting
$array['field'][] = $coluna["Field"];
– Sergio
I won’t know how to do it, you can help me?
– Marcos Vinicius
If this array should have the contents that are in the table then the response of the bigown is what you need and is much cleaner.
– Sergio
Can you help me in Updating of what I managed to do. He is assigning the return in
$array['field']
but this is inserting the index number. I need exactly the code demonstrated in Updating.– Marcos Vinicius
Marcos, you’ve been transforming the question and revealing new problems that weren’t in the original question. So the first answers lose meaning and the question becomes a salad. Please ask specific questions for specific problems and if you have a new problem that you cannot solve yourself ask a new question. As you noticed I went back on your question updates. Now the accepted answer is kind of out of date...
– Sergio