I have a database that stores information everytime someone downloads a file. It captures name email and the date stamp everytime they download the file (as requested by client).
I want to be able connect to the database and add up all duplicate entries. So if there are 10 results with the email [email protected] it will print "[email protected]; 10 downloads."
This is what i have tried so far. However it times out on the page:
function userFile($id) // $id = File ID
{
$order = "SELECT * FROM downloads WHERE dl_id='$id'";
$result = mysql_query($order);
while($row=mysql_fetch_array($result)){
$email = $row['email'];
$order = "SELECT * FROM downloads WHERE email='$email'";
$result = mysql_query($order);
$num_rows = mysql_num_rows($result);
print $row['email'] . ' ' . $num_rows;
}
}
There has to be an easier or better way of doing this. Any help is appreciated!
mysql_queryin new code, but if you must, always escape your SQL values correctly.