I need help with how to link this to a db

0
<div id="baba">
            <form action="rere.php" method="post">
    <div class="ficha">
    <?php
        //, GetSQLValueString($colname_USUARIO, "text"))
        $query_USUARIO = sprintf("SELECT * FROM productos");
        $refrescos = mysqli_query($conexion, $query_USUARIO);
        $row_refresco = mysqli_fetch_assoc($refrescos);
        $totalRows_refresco = mysqli_num_rows($refrescos);  
    ?>
        <img src="images/images.jpg" width="100%" height="100%" class="fotos">
</div>
        <?php do { ?>
        <div class="ficha">
            <div class="nombre">
           <?php echo $row_refresco['producto']; ?>
                <br></div>
        <img src="images/catalogo/<?php echo $row_refresco['fotos']; ?>" width="200" height="240" class="imagen">
            <div class="precio">
         <?php echo "<br>$ ".$row_refresco['precio'];
                if($row_refresco['producto'] == 'refrescos'){
                    $product = 'refrescos';
                }?>
                <input type="radio" name="<?php echo $product ?>" value="bien" onDblClick="unselect()" />
        </div>
</div>
<img src="" width="  ">
       </tr>
       <?php } while ($row_refresco = mysqli_fetch_assoc($refrescos)); ?>
            <div class="ficha">
        <label>Direcci&oacute;n</label>
<input type="text" id="direccion" name="direccion" value="Calle Morelos 104 interior B,Col. Centro,Texcoco,México"/> 
    <input type="submit" value="comprar">
            </div>
            </form>
        </div>
    
asked by Erik Gonzalez 02.12.2018 в 06:49
source

1 answer

0

For the clarification that you make in the comment, I think that you want to send those fields of the form and (at least) collect the value of the radio input.

What happens is that the value that you are going to collect in the file rere.php when sending the form is done through the attribute "name" (that is, in your case through the value that takes the variable $ product ), while the value you will have will be the one you have given in the "value" attribute (that is, in your case it will always be "good").

Note that your $ product variable will not always be defined, since it is inside an if. However, the radio input below where you use it is not inside that if, which means that under certain cases (when $ row_refresco ['product'] does not have the value "refreshments") the variable $ product will not be defined and you will loose an error.

However, the code becomes a bit difficult to read. It would be nice if you used the tools of the text editor to make it more readable and we can help you better.

    
answered by 02.12.2018 в 09:00