PHP mysql adding up duplicates at result -


i have database stores information everytime downloads file. captures name email , date stamp everytime download file (as requested client).

i want able connect database , add duplicate entries. if there 10 results email a@a.com print "a@a.com; 10 downloads."

this have tried far. times out on page:

function userfile($id) // $id = file id  {     $order = "select * downloads dl_id='$id'";     $result = mysql_query($order);     while($row=mysql_fetch_array($result)){              $email = $row['email'];         $order = "select * downloads email='$email'";         $result = mysql_query($order);         $num_rows = mysql_num_rows($result);         print $row['email'] . ' ' . $num_rows;     }  } 

there has easier or better way of doing this. appreciated!

have mysql work you. if understand requirements correctly need query this:

select email, count(*) num_rows downloads dl_id='$id' group email 

then php code this:

function userfile($id) // $id = file id  {     $order = "select email, count(*) `num_rows` downloads dl_id='$id' group email";     $result = mysql_query($order);     while($row=mysql_fetch_array($result)){              $email = $row['email'];         $num_rows = $row['num_rows'];         print $email . ' ' . $num_rows;     }  } 

i don't have php available here today, warned untested.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -