Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 30th, 2004, 12:57 AM
exequor exequor is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 190 exequor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 51 sec
Reputation Power: 2
doing an addition

i used this code to find the total of a field

php Code:
Original - php Code
  1.  
  2. $sql = "SELECT SUM(nreplies) AS total FROM frm_topics WHERE forumid = $forumid";
  3. $tot = mysql_query($sql);
  4. echo $tot;


but it returns Resource id #21. How do i get the correct result?

Reply With Quote
  #2  
Old March 30th, 2004, 05:33 AM
cjrobs cjrobs is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Southampton, England
Posts: 121 cjrobs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to cjrobs
RE: doing an addition

You've not retrevied the data from the SQL Result

Try
php Code:
Original - php Code
  1.  
  2. <?
  3. $sql = "SELECT SUM(nreplies) AS total FROM frm_topics WHERE forumid = $forumid";
  4. $result = mysql_query($sql);
  5. $array = mysql_fetch_array($result);
  6. $tot = $array['total'];
  7. echo $tot;
  8. ?>

Reply With Quote
  #3  
Old March 30th, 2004, 07:18 PM
exequor exequor is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 190 exequor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 51 sec
Reputation Power: 2
RE: doing an addition

thank you very much cjrobs. I really needed that for my forum.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > doing an addition


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway