<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>this has the same problem as the first solution
suggested...people with 5 downloads are now shown as having 50. People without
any downloads correctly have 0.</FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=sivaji2009@gmail.com href="mailto:sivaji2009@gmail.com">sivaji
j.g</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=support@drupal.org
href="mailto:support@drupal.org">support@drupal.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, April 09, 2010 2:06
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [support] Printing "0" when
a db query returns nothing</DIV>
<DIV><BR></DIV><BR><BR>
<DIV class=gmail_quote>On Fri, Apr 9, 2010 at 10:19 PM, Neil Coghlan <SPAN
dir=ltr><<A
href="mailto:neil@esl-lounge.com">neil@esl-lounge.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV bgcolor="#ffffff">
<DIV><FONT size=2 face=Arial>I am trying to print the number of downloads a
user's attachments have produced and am 95% there. I just don'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'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><?php<BR>$query= "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(
'sites/default/files/', file_downloads.filename )<BR>WHERE (files.uid =
$account->uid)";<BR>$results = db_query($query);<BR>while($output =
db_fetch_object($results)){<BR>print
$output->DownloadCount;<BR></FONT></DIV></DIV></BLOCKQUOTE>
<DIV><BR>print <FONT size=2 face=Arial>(is_int($output->DownloadCount)
&& (int) </FONT><FONT size=2 face=Arial>$output->DownloadCount >
0)</FONT><FONT size=2 face=Arial> ? </FONT><FONT size=2
face=Arial></FONT><FONT size=2 face=Arial>$output->DownloadCount :
NICE_FAT_ZERO</FONT><FONT size=2 face=Arial>;</FONT><BR> <BR></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV bgcolor="#ffffff">
<DIV><FONT size=2 face=Arial>}<BR>?></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't, the result is a blank space. How
can I print a nice fat "0"??</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT><BR></DIV></DIV></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Thanks<BR>Sivaji<BR>
<P>
<HR>
<P></P>-- <BR>[ Drupal support list | http://lists.drupal.org/
]</BLOCKQUOTE></BODY></HTML>