djpic Posted October 25, 2007 Share Posted October 25, 2007 All I want to do is get the total number of rows in a table. I know I can use mysql_rum_rows() but that deals with a query and I don't need a query. I just want to know how many rows there are using less resources than it having to count all the rows in SELECT statement. I heard somewhere that is was possible to pull it from a particular place that will not run a full query on a table in a database. Link to comment https://forums.phpfreaks.com/topic/74790-solved-simple-question-based-on-the-number-of-rows/ Share on other sites More sharing options...
Barand Posted October 25, 2007 Share Posted October 25, 2007 SELECT COUNT(*) FROM tablename Link to comment https://forums.phpfreaks.com/topic/74790-solved-simple-question-based-on-the-number-of-rows/#findComment-378174 Share on other sites More sharing options...
djpic Posted October 25, 2007 Author Share Posted October 25, 2007 that doesn't work. It just returns a value of: Resource id #3 Link to comment https://forums.phpfreaks.com/topic/74790-solved-simple-question-based-on-the-number-of-rows/#findComment-378188 Share on other sites More sharing options...
Barand Posted October 25, 2007 Share Posted October 25, 2007 OK, spoonfed solution $res = mysql_query("SELECT COUNT(*) FROM tablename"); $num_rows = mysql_result ($res, 0); Link to comment https://forums.phpfreaks.com/topic/74790-solved-simple-question-based-on-the-number-of-rows/#findComment-378191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.