in PHP, SQL

Return Number Of Rows With PHP From SQL Database

Occasionally working with SQL databases (not my beloved MySQL) I always struggled getting the number of rows in a consistant manner.

Until now…

It’s a simple fix. Add ‘ORDER BY’ to your SQL select. It doesn’t matter if you are just getting back items where the order doesn’t matter, use an order by clause in your select and you will always get the number of rows back successfully.