简体   繁体   中英

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  | me@me.com |xxxxxx|iPhone
 2  | you@me.com|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?

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.
 }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM