<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
.shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Arial Black";
        panose-1:2 11 10 4 2 1 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US link=blue bgColor=white vLink=purple>
<DIV><FONT size=2 face=Arial>that's worked fine for those members with 0
downloads, but for example, someone with 5 is now showing 50.</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=warren@vailtech.net href="mailto:warren@vailtech.net">Warren Vail</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:03
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [support] Printing "0" when
a db query returns nothing</DIV>
<DIV><BR></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Echo sprintf(“%01d”,
$count);<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<P class=MsoNormal><EM><B><I><FONT color=navy size=2 face="Arial Black"><SPAN
style="FONT-FAMILY: 'Arial Black'; COLOR: navy; FONT-SIZE: 10pt; FONT-WEIGHT: bold">Warren
Vail</SPAN></FONT></I></B></EM><FONT color=navy><SPAN
style="COLOR: navy"><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Vail Systems
Technology</SPAN></FONT><FONT color=navy><SPAN
style="COLOR: navy"><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"><A
title=blocked::mailto:warren@vailtech.net
href="mailto:warren@vailtech.net"><FONT size=3 face="Times New Roman"><SPAN
style="FONT-FAMILY: 'Times New Roman'; FONT-SIZE: 12pt">warren@vailtech.net</SPAN></FONT></A></SPAN></FONT><FONT
color=navy><SPAN style="COLOR: navy"><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">(510)
444-5380</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<DIV style="TEXT-ALIGN: center" class=MsoNormal align=center><FONT size=3
face="Times New Roman"><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center SIZE=2 width="100%">
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT size=2 face=Tahoma><SPAN
style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold">From:</SPAN></FONT></B><FONT
size=2 face=Tahoma><SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"> Neil
Coghlan [mailto:neil@esl-lounge.com] <BR><B><SPAN
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Friday, April 09, 2010 9:50
AM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> <A
href="mailto:support@drupal.org">support@drupal.org</A><BR><B><SPAN
style="FONT-WEIGHT: bold">Subject:</SPAN></B> [support] Printing "0" when a db
query returns nothing</SPAN></FONT><o:p></o:p></P></DIV>
<P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<P class=MsoNormal><FONT size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">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.</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">here's what I have so far (with
download count module installed which creates file_downloads
table)</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; FONT-SIZE: 10pt"><?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>}<BR>?></SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">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"??</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT size=2 face=Arial><SPAN
style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">regards<BR><BR>Neil</SPAN></FONT><o:p></o:p></P></DIV></DIV>
<P>
<HR>
<P></P>-- <BR>[ Drupal support list | http://lists.drupal.org/
]</BLOCKQUOTE></BODY></HTML>