how to fill the field of a form from a Mysql query?

-2
    <?php

    include("conexion.php");
    $idUsu=$_POST["id"];

    $sql="SELECT Nombre FROM usuario where idUsuario=$idUsu"; 
    $result=mysqli_query($conexion,$sql);
    ?>

and here the form where I want to show the name

    <form >
    <div class="form-row">

    <div class="form-group col-md-6">
    <label for="inputNombre">Nombre</label>
    <input type="text" class="form-control"  name="Nombre" value="$result">
    
asked by javier ventura 06.10.2018 в 01:30
source

1 answer

0

what you must do is create an associative arrangement by means of a while and then open the php language with its respective <?php ?> tags within the form as follows:

 <?php 
    include("conexion.php");
        $idUsu=$_POST["id"];
        $sql="SELECT Nombre FROM usuario where idUsuario=$idUsu"; 
        $result=mysqli_query($conexion,$sql);
        while ($res = mysqli_fetch_array($result)) {
        }
    ?>
   <label for="inputNombre">Nombre</label>
    <input type="text" class="form-control"  name="Nombre" value="<?php echo 
    $res['nombre']; ?>">
    
answered by 06.10.2018 / 08:18
source