View Single Post
Old 01-19-2013, 01:55 PM   PM User | #1
countrydj
Regular Coder

 
Join Date: Nov 2011
Location: Preston, UK
Posts: 130
Thanks: 36
Thanked 0 Times in 0 Posts
countrydj is an unknown quantity at this point
Counting occurences in MySql

I am writing a simple script to collect email addresses.
I want to collect ALL email addresses, even if they are duplicated.
However, I don't want to add the emaill address each time. I want to identify that the email address is already registered and then have another field [number] that will give the total number of times that the email address has been registered.
e.g The first time an email address is registered, it will put 1 into [number].
The second time the email address is registered it will put 2 into [number]
The third time the email address is registered it will put 3 into [number]
etc...

Up to now I have got:
PHP Code:
if($email != '') {
        
$qry "SELECT * FROM bf_users WHERE email='$email'";
        
$result mysql_query($qry);
        if(
$result) {
            if(
mysql_num_rows($result) > 0) { 
This will check if the email address already exists in the database, but I am now stuck.
Any help and advise will be very welcome.

Thanks,
__________________
The MAN, The MYTH, The LEGEND:
John C
________________________________
Support your local Country Music Club

Last edited by countrydj; 01-19-2013 at 04:43 PM..
countrydj is offline   Reply With Quote