mATOK Posted October 9, 2007 Share Posted October 9, 2007 Hi there, I would like to understand more what is returned when I perform a SQL queries. I process queries all the time and use something like the below $resusage = mssql_query($sqlusage); while ($resusage1 = mssql_fetch_array($resusage)) { echo $resusage1['username']; } $ttlTVA = array_count_values($resusage1); Now I am trying to count with array_count_values and it gives me an error saying that the supplied argument is not an array? My end goal is as follows, I am requesting records for users at a given location. I want to know how many total vaules exist between two user fields TVA and RF. Right now I have: Sum(Case r.RequestTypeId When 1 then 1 Else 0 End) As TVA, Sum(Case r.RequestTypeId When 2 then 1 Else 0 End) As RF In my SQL it spits out two numbers, TVA and RF for each user, I want a total count for the given location. Quote Link to comment https://forums.phpfreaks.com/topic/72485-php-sql/ Share on other sites More sharing options...
Orio Posted October 9, 2007 Share Posted October 9, 2007 It gives you this error because the value of $resusage1 after the loop is FALSE (that's what mssql_fetch_array() returns after the internal pointer in the result object reached the end). If you want to know how many rows have been fetched, IE how many time your loop is running every time, simply use the value returned by mssql_num_rows($resusage). Orio. Quote Link to comment https://forums.phpfreaks.com/topic/72485-php-sql/#findComment-365495 Share on other sites More sharing options...
mATOK Posted October 9, 2007 Author Share Posted October 9, 2007 unfortunately that does not work either Quote Link to comment https://forums.phpfreaks.com/topic/72485-php-sql/#findComment-365612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.