How to take while from this example and display only 1 data?

Asked

Viewed 40 times

0

How to take while from this example and display only 1 given?

    $query = $mysql->query("SELECT * FROM dados WHERE id='$id'");
    while($row = $query->fetch_array()){

    echo $row['nome'];
    }
  • Add LIMIT 1 in his query. Or use $row = $query->fetch_array(); echo $row[0]['nome';]

  • $Row = $query->fetch_array(); echo $Row[0]['name'];

  • using this option it appears only the first letter

  • $row = $query->fetch_array(); echo $row['nome'];

  • Thanks now it worked :D

1 answer

1

$query = $mysql->query("SELECT * FROM dados WHERE id='$id'");
    $row = $query->fetch_array();       

    echo $row['nome'];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.