Thread: count question
View Single Post
Old 02-16-2013, 12:07 AM   PM User | #4
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,191
Thanks: 217
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
@Fou-Lu thanks how about that i never used mysqli_fetch_row before i have always relied on fetch_array or fetch_object.

And it also looks like i dont even have to worry about extra elements on the result other than [0] because from what i gather from the docs it defaults to [0] and thats all i need as i am not repeating this in a loop so it will always be just [0] result on this. So just doing this will always get me the correct value.

PHP Code:

//get total customers 
$query "SELECT COUNT(*) FROM users"
$res =  mysqli_query($mycon,$query); 
$cntr mysqli_fetch_row($res);  
$totcust $cntr[0]; 
But that does bring up a question, i have seen at times when someone in the past has used MYSQLI_NUM | MYSQLI_ASSOC for example.
mysqli_fetch_array($resultval,MYSQLI_ASSOC)

So should i be replacing those with the normal fetch of just ($resultval) as that second parameter is not required anymore i dont think.



@felgall thanks, yes but i need to do this seperate because my other querys are in such a fashion that none of them pull all the rows, they are all limited by sorting vars and limiter status vars.

Last edited by durangod; 02-16-2013 at 12:11 AM..
durangod is offline   Reply With Quote