jamesjmann Posted April 16, 2015 Share Posted April 16, 2015 (edited) Is there a way to get the count of rows like this? $count = somefunctionthatreturnscount(mysqli_query($mysqli, "SELECT COUNT(*) FROM table")); Instead of... $count = mysqli_num_rows(mysqli_query($mysqli, "SELECT id FROM table")); //or even... $count = mysqli_fetch_array(mysqli_query($mysqli, "SELECT COUNT(*) as count FROM table")); Ultimately, I want the method that will get the count the quickest and if can be done similarly to the first code and still have good performance. Thanks in advance! Update: Reported post as duplicate. Need moderate to delete duplicates as that option is not appearing for me. Edited April 16, 2015 by jamesjmann Quote Link to comment Share on other sites More sharing options...
Barand Posted April 16, 2015 Share Posted April 16, 2015 I use $res = $mysqli->query("SELECT COUNT(*) FROM table"); list($count) = $res->fetch_row(); 1 Quote Link to comment Share on other sites More sharing options...
jamesjmann Posted April 16, 2015 Author Share Posted April 16, 2015 I use $res = $mysqli->query("SELECT COUNT(*) FROM table"); list($count) = $res->fetch_row(); This works, thank you! Quote Link to comment 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.