<br><br><div class="gmail_quote">On Fri, Apr 9, 2010 at 10:19 PM, Neil Coghlan <span dir="ltr">&lt;<a href="mailto:neil@esl-lounge.com">neil@esl-lounge.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">







<div bgcolor="#ffffff">
<div><font size="2" face="Arial">I am trying to print the number of downloads a 
user&#39;s attachments have produced and am 95% there. I just don&#39;t know how to 
print zero if the SUM returns nothing.</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">here&#39;s what I have so far (with download count 
module installed which creates file_downloads table)</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">&lt;?php<br>$query= &quot;SELECT SUM(count) AS 
DownloadCount<br>FROM upload<br>JOIN files <br>ON upload.fid = files.fid<br>JOIN 
file_downloads<br>ON files.filepath = CONCAT( &#39;sites/default/files/&#39;, 
file_downloads.filename )<br>WHERE (files.uid = $account-&gt;uid)&quot;;<br>$results 
= db_query($query);<br>while($output = db_fetch_object($results)){<br>print 
$output-&gt;DownloadCount;<br></font></div></div></blockquote><div><br>print <font size="2" face="Arial">(is_int($output-&gt;DownloadCount) &amp;&amp; (int) </font><font size="2" face="Arial">$output-&gt;DownloadCount &gt; 0)</font><font size="2" face="Arial"> ? </font><font size="2" face="Arial"> </font><font size="2" face="Arial">$output-&gt;DownloadCount : NICE_FAT_ZERO</font><font size="2" face="Arial">;</font><br>

 <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div bgcolor="#ffffff"><div><font size="2" face="Arial">}<br>?&gt;</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">works perfectly for those whose content have 
created downloads. For those who haven&#39;t, the result is a blank space. How can I 
print a nice fat &quot;0&quot;??</font></div>
<div><font size="2" face="Arial"></font> <br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Thanks<br>Sivaji<br>