I am trying to get a script to show which companies have more than one user per account number. It sort of works, but I wanted to see how many were actually being used.
Code:
$table_name=(USER);
$query = "SELECT organization_title, email, account_number,COUNT(*) AS Count
FROM $table_name
GROUP BY account_number
HAVING Count > 1; ";
$result = mysql_query($query) or die("No Account Numbers Present!" . mysql_error());
echo "<table>";
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td> Account Number: ' .$row["account_number"] .'</td>';
echo '<td> Organization: ' .$row["organization_title"] .'</td>';
echo '<td> Account Name:' .$row["account_name"] .'</td>';
echo '<td> Email: ' .$row["email"] .'</td>';
echo '<td>' .$row["COUNT({account_number})"] .'</td>';
echo '</tr>';
}
echo "</table>";
Results:
Notice: Undefined index: account_name in /path/to/file.php on line 37
Notice: Undefined index: COUNT({account_number}) in /path/to/file.php on line 39
Notice: Undefined index: account_name in /path/to/file.php on line 37
Notice: Undefined index: COUNT({account_number}) in /path/to/file.php on line 39
Notice: Undefined index: account_name in /path/to/file.php on line 37
Notice: Undefined index: COUNT({account_number}) in /path/to/file.php on line 39
Notice: Undefined index: account_name in /path/to/file.php on line 37
Notice: Undefined index: COUNT({account_number}) in /path/to/file.php on line 39
Account Number: 001A050i07agtt6IAAOrganization: Some Org Account Name:Email: email@domain.com
Account Number: Hh7wf101Fp50isBcvqOrganization: Another Company Inc Account Name:Email: test@domain.com
Account Number: qev0w31vMopohBi27mOrganization: Account Name:Email: testing@mydomain.com
Account Number: qev0j31vM0ko1Bi27sOrganization: Account Name:Email: anotheremail@domain.com
It's balking at COUNT. How is the best way to tell how many and echo that out?
Thanks!