tags:

views:

47

answers:

3
$sql = "select count(userId) from tblUser";
$result=mysql_query($sql,$link)or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_NUM); 
echo $row[1];   

print_r($row); is displaying no of records but whu echo is not working

+3  A: 
Sarfraz
it will give `1` because I have used `count`(userId).
pamela
That will show the number of rows brought back (1 in this case) which would be incorrect. If pamela had a query like `select userId from tblUser` it would then do what I assume she's looking for.
manyxcxi
@pemela: I have updated my answer.
Sarfraz
+1  A: 

mysql_fetch_array is zero counted. You will want to echo $row[0];

http://php.net/manual/en/function.mysql-fetch-array.php

manyxcxi
+1  A: 

Are you sure about the array index?

echo $row[0];
Ehsan