Value does not fit inside the text box

1

Hello, how are you guys? So, I'm having an annoying problem, I've done a function that returns data from a certain table field, to insert it into the text box of a form; But, the value returned from the field appears on top of the text box, not within the value="" attribute. I'm just using HTML and PHP to build the algorithm and I plan to not use javascript for now. If someone answers, thank you very much for your help, because I can not solve this problem.

      //////////////// Editar ///////////////////////
  function select($id)
  {
    global $conn;
    $stmt = $conn->prepare("SELECT usuario FROM usuarios WHERE id = $id");
    $stmt->execute();
    $row_user = $stmt->fetch(PDO::FETCH_ASSOC);
    echo $row_user['usuario'];
  }
  ///////////////////////////////////////////////
  if (isset($_GET['id']) and $_GET['acao'] == 'editar' and $_GET['campo'] == 'usuario')
  {
    echo ('
      <form method=post>
        <input type=text name=edit_usr value='.select($_GET['id']).'><br>
        <input type=submit name=edit_envia value=Editar>
      </form>

    ');

    
asked by anonymous 24.08.2018 / 01:43

1 answer

1

You are giving a echo to the function when you should return the value with a return .

Change echo $row_user['usuario']; to return $row_user['usuario']; .

    
24.08.2018 / 01:50