Value does not fit inside the text box

Asked

Viewed 37 times

1

Hey, what’s up, guys? So, I have a problem, I made a function that returns data from a certain table field, so to insert it into the text box of a form; but, the returned value of the field appears on top of the text box, not inside the value="" attribute. I’m only using HTML and PHP to build the algorithm and, I intend not to use javascript for now. If someone answers, I thank you very much for your help, because I am not able to solve such a 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>

    ');

inserir a descrição da imagem aqui

  • Ever tried to change the echo $row_user['usuario']; for return $row_user['usuario'];?

  • No, I’ll try now

  • Eiiita kkkk, it was perfectly mano! Brigadão ae, even :)

1 answer

0


You’re giving a echo in the function when it should return the value with a return.

Exchange the echo $row_user['usuario']; for return $row_user['usuario'];.

  • Opa mano worked, it is that I thought that giving the Return, the function would not return me no output, and so I say a print on the screen, I sent a direct echo, but apparently was wrong. Thank you again, bro!

  • Ho fera, look at this, I discovered the cause but I don’t know anything about it, see my comments in this post https://answall.com/questions/324325/como-coloca-link-em-imagens-com-div

  • @Leocaracciolo guy, I’m kind of in no condition to analyze the issue now... but let it cool down and I’ll take a look

  • No stress, and if you’re interested.

  • @Leocaracciolo clear my friend... I am interested yes... I will take a look

Browser other questions tagged

You are not signed in. Login or sign up in order to post.