How do I get a specific data from the BD and not the first one I find?

0

I am currently doing a query with php to bring me a specific data of the user that is being used, I have the following, but it brings me the first data that it finds from that column (company), and not the user-related one logged in at the moment.

<?php 
    $consulta = "SELECT * FROM wck_usuarios"; 
    $ejecutar = mysql_query($consulta, $link); 
    $i = 0; 
    while($fila = mysql_fetch_array($ejecutar))
    { 
        $id = $fila['id']; 
        $empresa = $fila['empresa']; 
        $i++; 
        ?>
            <input class="refor" type="text" name="empresa" readonly="" value="<?php echo utf8_encode($empresa); ?>"> 

        <?php 
    } 
    mysql_close(); 
?>
    
asked by Sergio 20.06.2017 в 15:51
source

1 answer

1

To make queries with conditions - in this case you want to bring data from a specific user -, you must specify this condition with Where :

SELECT * FROM wck_usuarios WHERE usuario = 'usuario requerido' 
    
answered by 20.06.2017 / 16:10
source