Welcome to WebmasterWorld Guest from 54.158.227.99

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

# Display Duplicates

7:13 pm on Dec 14, 2011 (gmt 0)

#### Junior Member

joined:Oct 19, 2011
posts: 166

I am creating a new function for the project. Need to display all members that have the same account_number and show how many of them there are. I did something wrong because I'm getting errors along with the actual account numbers that have more than one.

error_reporting(E_ALL);
session_start();
include('config.php');

$table_name=(USER);$query = "SELECT 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());$sql = "SELECT * FROM $table_name";$data = mysql_fetch_array($sql);$firstname=mysql_real_escape_string($data['firstname']);$organization=mysql_real_escape_string($data['organization_title']);$lastname=mysql_real_escape_string($data['lastname']);$username=mysql_real_escape_string($data['member_login']);$password=mysql_real_escape_string($data['member_password']);$email=mysql_real_escape_string($data['email']); echo "<table>"; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>' .$row["account_number"] .'</td>';
echo '<td>' .$organization .'</td>'; echo '<td>' .$firstname .'</td>';
echo '<td>' .$lastname .'</td>'; echo '<td>' .$username .'</td>';
echo '<td>' .$password .'</td>'; echo '<td>' .$email .'</td>';
echo '<td>' .$row['COUNT(account_number)'] .'</td>'; echo '</tr>'; } echo "</table>"; Output is as follows: Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in path\to.accounts.php on line 30 Notice: Undefined index: COUNT(account_number) in path\to.accounts.php on line 49 Notice: Undefined index: COUNT(account_number) in path\to.accounts.php on line 49 Notice: Undefined index: COUNT(account_number) in path\to.accounts.php on line 49 Notice: Undefined index: COUNT(account_number) in path\to.accounts.php on line 49 Hh7wfo01Fp507sBcvq qev0631vM0po1Bi27m qev0631vM0po1Bi27s This part is right. It's likely a very simplle fix, but I cannot see it right now. Thanks for the help! #### enigma1 2:39 pm on Dec 15, 2011 (gmt 0) #### Senior Member joined:Apr 30, 2007 posts:1394 votes: 0$sql = "SELECT * FROM $table_name";$data = mysql_fetch_array(\$sql);

You're pulling rows without making a query first.

3:16 pm on Dec 15, 2011 (gmt 0)

#### Junior Member

joined:Oct 19, 2011
posts: 166

I knew it was something simple. How do I get the COUNT to work right. I wanted it to show how many users there were for the one account. Or am I going about it the wrong way?
Thanks!