John Hesch

Echoing my thoughts and interests

Sometimes I want to do something so simple in PHP and the code escapes me and I can't figure it out. One of the purposes of my website is to house code snippets that I can refer back to.

Here is the code to get the unique number of entries in a table.

PHP:
  1. $users = mysql_query("SELECT name FROM $tablename GROUP BY name");
  2. while ($data = mysql_fetch_row($users)) {$total_users++;}
  3. echo ($total_users.' unique people have commented');

Found via codegrrl.com.

Comments are closed.

Graytone | Design: Tenant Report