I am trying to get few entries of a Table using this code
$statement = $conn->prepare('SELECT * FROM players WHERE longitude > :long1 AND longitude < :long2 AND latitude > :lat1 AND latitude < :lat2 AND id != :mPlayerId ');
$statement->bindParam(':long1', $long1, PDO::PARAM_INT);
$statement->bindParam(':long2', $long2, PDO::PARAM_INT);
$statement->bindParam(':lat1' , $lat1, PDO::PARAM_INT);
$statement->bindParam(':lat2' , $lat2, PDO::PARAM_INT);
$statement->bindParam(':myPlayerId' , $myPlayerId, PDO::PARAM_INT);
$statement->execute();
if(!($players = $statement->fetchAll(PDO::FETCH_ASSOC)))
{
return false;
}
$conn = null;
} catch(PDOException $e) {
throw $e;
}
Now I want to get each entry . Suppose each entry contains id, name, email.
How can i get each entries data?
I have this code in my mind, can someone check if that’s what i need or need something else?
foreach($players as $player)
{
this->ShowResult($player->id,$player->email);
}
Use something like
Should do the thrick