$query = "SELECT id FROM words where word ='abc'";
$result2 = $conn1->query($query);
//fetch the data from the database
while ($row = $result2->fetch_assoc() ) {
echo "id is:".$row['id'];
}
where $conn1 is the connection variable
$conn1 = new mysqli($servername, $username, $password, $dbname);
solved How to get value of cell knowing neighboring cell from same row in sql db?