enter SQL query in an input with PHP

0

I am trying to query a BDD with php to show the results through an HTML input.

To show the result I do the following:

while($fila=mysqli_fetch_array($resultados, MYSQLI_ASSOC)){

        $emp = $fila['Emp_Nom'];
{

And I show it through the input like this:

 <input type="text" readonly value=<?php echo $emp ?>> 

The code shows me the text but only the first word where there is a space.
To try to solve it instead of using a input I used a textarea and I modified it with css so that it has the same appearance as input .

Is there any way to enter the full results of a query in input ?

Thanks in advance!

    
asked by gmarsi 02.04.2017 в 02:35
source

2 answers

2

You can concatenate a single quote to the $ emp variable like this:

 <input type="text" readonly value=<?php echo "'" . $emp . "'" ?>> 

In this way the input shows all the content of the variable.

    
answered by 02.04.2017 / 02:49
source
1

Also, if you have enabled in your etc / php / php.ini the Short Tag

short_open_tag = On

You could do it in the following way

<input type="text" readonly value="<?=$emp?>"> 

O

<input type="text" readonly value="<?php echo $emp;?>">
    
answered by 02.04.2017 в 08:59