Track downloads with PHP?

Miscellaneous Forums/General Discussion/Track downloads with PHP?

Little snippet that I use to keep track of total number of downloads as well as direct the user to the item of interest:

include "_private/database.inc";

$result = mysql_query("SELECT * FROM product_downloads WHERE name = '$product'");
$row = mysql_fetch_array($result);
if (strlen($row) != 0)
{
	$total = ++$row["downloads"];
	$result = mysql_query("UPDATE product_downloads SET downloads='$total' WHERE name = '$product'");
}
if ($result)
{
	$myfile = "http://webappstogo.com/".$pfile;
	header("Location: $myfile");
	exit;
}

$pfile is passed in (URL) and looks like this:
http://www.webappstogo.com/dlds.html?&product=3DXmas&pfile=3dxmas/3DXmasSetup.exe

Table structure:
   Field  		Type		Attributes	Null 	Default	Extra  
   id			int(11)   			No    		auto_increment              
   name  		varchar(40)   			No                  
   description  	varchar(40)   			No                  
   downloads  		int(11)   			No  	0                
   video  		int(11)   			No  	0                
   google_ad  		int(11)   			No  	0	                
   google_click 	int(11)   			No  	0                
   halloween_ad 	int(11)   			No  	0                
   app_online_click	int(11)   			No  	0                
   link  		text   				No                
   backup  		int(11)   			No  	0               

It's quick and simple and accomplishes my own tasks. However, it will not keep track of completion of downloads. I really don't need that data.