If user leave comment, print "You have already written a comment" how to show this 'You have already written a comment' if user have comment in this node -)

Thanks for any help)
Try this

function custom_cv_node_view($node, $view_mode, $langcode) {
 global $user;
  if ($view_mode == 'teaser') { /* Teaser */
      $cid = db_query('SELECT cid FROM {comment} WHERE uid= :uid AND nid = :nid', array(':uid' =&gt; $user-&gt;uid, ':nid' =&gt; $node-&gt;nid))-&gt;fetch();
      if($cid) {
          $node-&gt;title = $node-&gt;title.' (Commented)';
      }
  }
}