Get values from only one row of a table

0

Hello, I have a project, and I would like it, when the user entered your account, could, through a PHP action, see your basic data, taking only values from that table, here is what I have so far: p>

$selec = "SELECT * FROM usuarios";
$selec_query = mysql_query($selec) or die(mysql_error());

    $row = mysql_fetch_array($selec_query);
        $nome = $row['nomealuno'];
        $cidade = $row['cidadealuno'];
        $uf = $row['ufaluno'];
        $nome = $row['nomealuno'];
        $datanasc = $row['datanascaluno'];

        echo "Login: ";
        echo $row['login'];
        echo "<br> Nome: ";
        echo "$nome";
        echo "<br> Cidade: ";
        echo "$cidade";
        echo "<br> UF: ";
        echo "$uf";
        echo "<br> Data de nascimento: ";
        echo "$datanasc";

The problem is that only the first login appears, and all the fields of the tables are with their names, I did not find any problems similar to mine here, much less a problem evident in the code.     

asked by anonymous 12.11.2015 / 12:50

1 answer

3

This query

$selec = "SELECT * FROM usuarios";

You are selecting all records in the usuarios table.

Here

$row = mysql_fetch_array($selec_query);

$row gets a result line (the first one in this case).

What you need to do is to limit your select to bring only the user record that you want to present the information. For this you will need to add a where clause in query .

$selec = "SELECT * FROM usuarios WHERE id = $idUsuario";
    
12.11.2015 / 13:04