idoodler
idoodler

Reputation: 3545

How to get value of row in mySQL with specific Value in PHP

I am trying to get a value of row with a specific value of a mySQL DB.

This is how my row looks like

row | email     | uuid | device
 1  | [email protected] |xxxxxx|iPhone
 2  | [email protected]|yyyyyy|iPod

So for example I want to get the uuid in row 2, I have the email.

This is how my mysql_query looks like:

$result = mysql_query("SELECT * FROM users WHERE email = '{$email}'");
    echo(mysql_result($result, 0)); #0 is email, but I need uuid, so 1

but I only can get the email.

Does anyone know how to get the uuid?

Upvotes: 0

Views: 59

Answers (2)

bart2puck
bart2puck

Reputation: 2522

look into switching over to pdo or mysqli_. but otherwise why not:

 $result = mysql_query("SELECT * FROM users WHERE email = '{$email}'");
 while($row = mysql_fetch_array($result))
 {

      echo $row['uuId'] . "," . $row['email'] . "," . $row['device'] . "<br>";
      //or whatever data you want.
 }

Upvotes: 1

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

You can use

while ($row = mysql_fetch_assoc($result)) {
    echo $row['email'];
    echo $row['uuid'];
    echo $row['device'];

}

BTW start using mysqli_* functions mysql_* functions are deprecated.

Upvotes: 0

Related Questions