0
I’m trying and I can’t seem to do the following:
I thought to "automate" the system reporting process that I am doing, for this, when registering the PRODUCT, you also register the column id name and the product id name, thus:
That way I get through GET to define which table, id column, and product name I have to pull. For this, I play all the information in the URL:
So when the person clicked on the product, I already have all the information I need (which table I need to get the information, etc.) through the code below:
<?php
$produtos = listaProdutos($conexao);
$tabela = $_GET['tabela'];
$coluna = $_GET['coluna'];
$modelo_produto = $_GET['modelo_produto'];
$produtos_id_produto = $_GET['produtos_id_produto'];
$nome_produto = $_GET['nome_produto'];
$sigla_produto = $_GET['sigla_produto'];
?>
<table>
<tr>
<td><h3>Qual modelo de <?=$nome_produto?> você deseja anunciar?</h3></td>
</tr>
</table>
<td width="250px" id="anuncios" name="anuncios">
<?php
$anuncio= mysqli_query($conexao,"SELECT * FROM $tabela order by $modelo_produto");
echo "<select class='btn btn-link' name='anuncios' id='anuncios'>";
while($reg = mysqli_fetch_object($anuncio)){
echo "<option value='$reg->coluna'>$reg->modelo_produto</option>";
}
echo "</select>";
?> </td>
<table>
<tr>
</tr>
</table>
And here comes the problem, in the SELECT
i can select what i want through the GET with the $table (which informs the table which has to pull the information).
It even works, but when it comes to displaying, it doesn’t show the names:
In the table that must be selected (batteries) are all values:
I believe that he is not able to locate the correct field through the GET that should appear, which in this case is modelo_bateria
I need suggestions on how I can echo the "model_battery field".
echo "<option value='$reg->coluna'>$reg->modelo_produto</option>";
NOTE: If I change from "modelo_product" to "modelo_battery" it appears with the values correctly:
Then try : echo "<option value='$reg->column'>$reg->$modelo_product</option>";
– Wagner Soares
When I do this, it does not locate any value, appears "empty" the field of select @Wagnersoares
– Rogério de Sá Jr.
From what I understand the value "model_battery" will come in the variable $modelo_product. That’s not it?
– Wagner Soares
What is the structure of the table "batteries" ?
– Alisson Acioli
@Wagnersoares This, exactly, but when I put this way $modelo_product, it does not appear anything to be selected
– Rogério de Sá Jr.
@AlissonAcioli 
id_bateria / produtos_id_produto / produto_classe / fabricantes_id_fabricante / baterias_familias_id_bateria_familia / modelo_bateria / baterias_tipos_id_bateria_tipo / voltagem_v / capacidade_mah / capacidade_wh /cnx_dtap_pt
– Rogério de Sá Jr.