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 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? 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 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 Link to comment https://forums.phpfreaks.com/topic/42560-odbc_num_rows/#findComment-206537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.