I am trying to retrieve from db the total number of pages written by a certain user using the below code:
function getPagesNoById($id) {
if ($id) {
$sql_query = "SELECT COUNT(page_id) FROM `texts` WHERE `user_id` = '" . $id . "'";
$query = mysql_query($sql_query)or die(mysql_error());
$cnt = mysql_num_rows($query);
mysql_close($conn);
$result = mysql_query($query);
return $result;
}
return false;
}
print getPagesNoById(7);
But the result is empty. Is there something wrong with it ?
Thanks in advance