NightMonkey Posted March 13, 2007 Share Posted March 13, 2007 Hi, I am trying to find out the number of rows there are in a record set that I have obtained from an odbc database. I have tried using the odbc_num_rows function but it always returns -1. I was told that this is a bug where its only returns the number of rows that have been accessed. If this is the case I could traverse every row in the record set counting the rows as I go but I was hoping there would be a simpler way of doing this. Can anyone offer any suggestions? Thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/42560-odbc_num_rows/ Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 $result = mysql_query("SELECT * FROM yourtable"); $rows = mysql_num_rows($result); change the 'yourtable' with your own and it should work out, setting the number of rows to $rows? Quote Link to comment https://forums.phpfreaks.com/topic/42560-odbc_num_rows/#findComment-206533 Share on other sites More sharing options...
artacus Posted March 13, 2007 Share Posted March 13, 2007 Actually, a more efficient way is: SELECT COUNT(*) FROM yourtable Quote Link to comment https://forums.phpfreaks.com/topic/42560-odbc_num_rows/#findComment-206536 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 I have lots of room to improve Quote Link to comment https://forums.phpfreaks.com/topic/42560-odbc_num_rows/#findComment-206537 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.