$query = "SELECT COUNT(*) FROM tablename WHERE link = '1'"; $result = mysql_query($query); $count = mysql_result($result, 0);
This means that you donโt transfer all your data between the database and PHP, which is obviously a huge waste of time and resources.
For what it's worth, your code didnโt actually count the number of rows - it would give you 2x the number of columns, since you are counting the number of elements in an array representing one row (and mysql_fetch_array gives you two entries in the array for each column - one numeric and one for the column name)
Chris
source share