I need help with how to link this to a db

<div id="baba">
            <form action="rere.php" method="post">
    <div class="ficha">
        //, 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">
        <?php do { ?>
        <div class="ficha">
            <div class="nombre">
           <?php echo $row_refresco['producto']; ?>
        <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()" />
<img src="" width="  ">
       <?php } while ($row_refresco = mysqli_fetch_assoc($refrescos)); ?>
            <div class="ficha">
<input type="text" id="direccion" name="direccion" value="Calle Morelos 104 interior B,Col. Centro,Texcoco,México"/> 
    <input type="submit" value="comprar">
asked by Erik Gonzalez 02.12.2018 в 06:49

1 answer


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