-2

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];
gunr2171
  • 16,104
  • 25
  • 61
  • 88
Sanoop S
  • 73
  • 1
  • 1
  • 4

1 Answers1

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];
AeJey
  • 1,447
  • 20
  • 40