在php中检索计数

I need to retrieve the count of a field name called remark corresponding to a particular user.

select count(remark) from attendance where username=_POST['username']

How will I implement this in php? I need to store the count to a variable $totalcount.

This is what i tried out:

$result = mysql_query("select count(1) FROM attendance where stud_id='$_POST['user']'");
$row = mysql_fetch_array($result);

$total = $row[0];

Also quotes are not used properly in the query string. Try this code.

$result = mysql_query("select count(*) FROM attendance where stud_id='".$_POST['user']."'");
$row = mysql_fetch_array($result);

$total = $row[0];