Error with mysqli_fetch_array?

0

Can you explain why?

Next the code

<?php
$con = mysqli_connect("localhost", "root", "", "codigofacilito")or die("error");
?>

<html>
<head>
    <meta charset="UTF-8">
    <title>Crud</title>
</head>
<body>
    <form method="POST" action="index.php">
        <center>
            <label>Nombre:</label>
            <input type="text" name="nombre" placeholder="Escriba su nombre"><br/><br/> 
            <label>Contraseña:</label>
            <input type="password" name="pw" placeholder="Escriba su contraseña"><br/><br/>
            <input type="submit" name="insert" value="insertar datos">
        </center>
    </form>  
</body>

<?php
if (isset($_POST['insert'])) {
    $usuario = $_POST['nombre'];
    $pw = $_POST['pw'];

    $insertar = "INSERT INTO codigof (nombre, pw) values('$usuario','$pw ')";
    $ejecutar = mysqli_query($con, $insertar)or die("error al conectarse");

    if ($ejecutar) {
        echo "<h3>datos insertados<h3>";
    }
}
?>


<table width="500" border="2" style="background-color: #F9F9F9">
    <tr>
        <th>nombre</th>
        <th>password</th>
        <th>editar</th>
        <th>borrar</th>


    </tr>

    <?php
    $consulta = "SELECT * FROM codigof";
    $ejecutar = mysqli_query($con, $consulta);

    $i = 0;

    while ($fila = mysqli_fetch_array($con, $ejecutar)) {
        $nombre = $fila['nombre'];
        $password = $fila['pw'];

        $i++;
        ?>

        <tr align="center">
            <td><?php echo $nombre; ?></td>
            <td><?php echo $password; ?></td>
            <td> <a href="index.php?editar-<?php echo$id; ?>"</a>Editar</td>
            <td> <a href="index.php?borrar-<?php echo$id; ?>"</a>Eliminar</td>

        </tr>

    <?php } ?>
</table>

</html>
    
asked by andres_tam 31.05.2017 в 03:13
source

0 answers