<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=ISO-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"></HEAD>
<BODY bgColor=#ffffff text=#000000>
<DIV><FONT size=2 face=Arial>this seems to work!!</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>thanks Jamie and to everyone else for lending a
hand.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Neil</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=hovercrafter@earthlink.net
href="mailto:hovercrafter@earthlink.net">Jamie Holly</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:18
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [support] Printing "0" when
a db query returns nothing</DIV>
<DIV><BR></DIV>Cast it as an integer:<BR><BR><FONT size=2 face=Arial>print
(int) $output->DownloadCount;</FONT><BR><PRE class=moz-signature cols="72">Jamie Holly
<A class=moz-txt-link-freetext href="http://www.intoxination.net">http://www.intoxination.net</A>
<A class=moz-txt-link-freetext href="http://www.hollyit.net">http://www.hollyit.net</A></PRE><BR>On
4/9/2010 12:49 PM, Neil Coghlan wrote:
<BLOCKQUOTE cite=mid:5DB08701C0F54B42BD24644922E311F5@Neil type="cite">
<META name=GENERATOR content="MSHTML 8.00.6001.18876">
<STYLE></STYLE>
<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> </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> </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>}<BR>?></FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT size=2 face=Arial>regards<BR><BR>Neil</FONT></DIV></BLOCKQUOTE>
<P>
<HR>
<P></P>-- <BR>[ Drupal support list | http://lists.drupal.org/
]</BLOCKQUOTE></BODY></HTML>