I have a simple pdo prepared query:
$result = $db->prepare(\"select id, course from coursescompleted where person=:p\");
$result ->bindParam(\':p\', $
You can use this
prepare("select id, course from coursescompleted where person=:p");
$result ->bindParam(':p', $q, PDO::PARAM_INT);
$result->execute();
$rows = $result->rowCount();
echo $rows;
?>
This sometimes does not work on SELECT queries. But based on personal experience, and since you didn't mention porting it to other database systems, it should work on MySQL.
More info is in PHP manual here