Select the values of the "select" through the "GET"

0

I'm trying and can not do the following:

I thought of "automating" the process of reports of the system that I am doing, by registering the PRODUCT, you also register the name of the column id and the name of the product id, as follows:

Thatway,IgetthroughGETtodefinewhichtable,idcolumn,andproductnameIhavetopull.Forthis,IplayalltheinformationintheURL:

Sowhenthepersonclicksontheproduct,IalreadyhavealltheinformationIneed(whichtableIneedtogettheinformation,etc)throughthecodebelow:

<?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>Qualmodelode<?=$nome_produto?>vocêdesejaanunciar?</h3></td></tr></table><tdwidth="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% with% I can select what I want through GET with the $ table (which informs the table that it has to pull the information).

It even works, but at the time of displaying, it does not show the names:

Beingthatinthetablethatmustbeselected(batteries)areallvalues:

IthinkhecannotfindthecorrectfieldthroughtheGETthatshouldappear,whichinthiscaseisSELECT

IneedsuggestionsonhowIcanechothe"template_file" field.

 echo "<option value='$reg->coluna'>$reg->modelo_produto</option>";

NOTE: If I change from "product_product" to "model_product" it appears with the values correctly:

    
asked by anonymous 30.03.2017 / 22:04

1 answer

0

From what you said in the comments, your structure of the batteries table is:

  • bat_id
  • product_id_product
  • product_class
  • manufacturer_id_manufacturer
  • baterias_familias_id_bateria_familia
  • template_battle
  • baterias_tipos_id_bateria_tipo
  • voltagem_v
  • capacity_mah
  • capacity_wh cnx_dtap_pt

Your query would be the same as:

"SELECT * FROM baterias order by modelo_bateria"

The problem I think is here:

echo "<option value='$reg->coluna'>$reg->modelo_produto</option>";

Because you are trying to return the columns column and product_model , but in your structure it does not, so it does not return anything.

Try this:

echo "<option value='$reg->$coluna'>$reg->$modelo_produto</option>";

If you do not, try:

echo "<option value='$reg->{$coluna}'>$reg->{$modelo_produto}</option>";
    
31.03.2017 / 23:10