Hack Forums
[PHP] Count total sql row in php - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Count total sql row in php (/showthread.php?tid=5985043)



Count total sql row in php - Zan0n - Jun 30, 2019

$counthash = $db->getRows('SELECT * FROM table WHERE hash='.strtoupper($temphash).' ');

how to count affected row??


RE: Count total sql row in php - Nachfolger - Jun 30, 2019

(Jun 30, 2019 08:53 AM)zan0n Wrote:  $counthash = $db->getRows('SELECT * FROM table WHERE hash='.strtoupper($temphash).' ');

how to count affected row??
Affected rows or selected rows? Are you even using every single result returned in that query or are you just wasteful?

Code
SELECT COUNT(*) FROM table WHERE hash='. strtoupper($temphash) .'
1. Select a indexed row for counting, not the entire row. (eg. COUNT(id))
2. Use prepared statements unless you're a moron.