1$sql = $dbh->prepare("SELECT COUNT(*) AS `total` FROM directory WHERE telephone = :phone");
2$sql->execute(array(':phone' => $telephone));
3$result = $sql->fetchObject();
4
5if ($result->total > 0)
6{
7 echo 'The telephone number: ' . $telephone. ' is already in the database<br />';
8}
9else
10{
11 echo 'No rows matched the query.';
12}
13