how can I save all the data within a table with php

3

    <?php
    if (isset($_POST['buscar'])) {
        $grado=$_POST['grado'];
        $sec=$_POST['seccion'];
        $query="SELECT * FROM estudiante WHERE Grado='$grado' AND Seccion='$sec'";
        $resultado=$conexion->query($query);
        while ($row=$resultado-> fetch_assoc()) {
            $targeta=$row['CodigTarge']; ?>
            <tr>            
                <td class="center" ><input type ="text" readonly="readonly"  name="targeta" value="<?php echo $targeta; ?>"/></td>
                <td class="despla" ><?php echo $row['nombre']?><?php echo $row['apellido']?></td>
                <td class="mod"  >"><input type ="text" required name="nota" placeholder="salario" value=""/>
                </td>
            </tr>        
            <?php
        }
    } else {
            ?>
            <tr> <td class="center">ingrese grado y seccion</td></tr>
            <?php
        }
    ?>			     
</tbody>
</table>
<input  type = "submit" value="Guardar" name="Guardar"/>
<?php
if (isset($_POST['Guardar'])) {
        $resultado=[];
        $captura=array($_POST['targeta']=>$_POST["nota"]);
        foreach ($captura as $targeta=>$nota) {
            echo "su  numero de targeta es $targeta tine nota $nota.<br/>";
        }
    }

?>

** this is my code I have the problem that I can not save all the rows of the table I only add the last one **

    
asked by hilario 14.10.2018 в 04:57
source

1 answer

1

Correct. You must send the data of the post in array mode, that is, you must put the name of the input of the form with the name adding brackets, that is: name="card []", eye that is written card. The same with all inputs:)

Greetings!

    
answered by 14.10.2018 в 05:45