![]() |
Help needed on first try at Database Query!
I wasn't sure if this is the right section to post but I'll try here...
I'm trying to make a Database query, This will be my first one, So please be nice.. ok heres what I'm trying to do.. I have a site I'm doing for a support group. I have a userfield that members can choose a number, What I need is a database query that will add-up all the numbers and give a total... Heres my failed stab at it.. Code:
$result_allweight = $DB_site->query(" btw, This code works but its only giving me the total of members not whats inside the "Field7" Table! |
If I understand what I think you're trying to accomplish...
Try this, see if it does what you need: PHP Code:
If anyone notices any obvious flaws in that above code, feel free to point them out, thanks. |
I'm getting this error after using your code. :ermm:
Code:
Invalid SQL: The site is for a weightloss supprot group and during registering they have a userfield option (field7) where they can put in how much weight they lost. What I'd like is a total of all the members weight loss added up and shown on the forum home page. The code I posted in the first post works somewhat as its returning the amount of tables (members) and its not adding whats in the "Field7" table.. :disappointed: |
What are you using for the $searchclause var?
|
Quote:
Like I said this is my FIRST try at php/mysql coding! |
Get rid of the comma after the COUNT(field7) AS total, <-
That should sort it out |
Quote:
|
Can someone help plz??? :confused:
|
Please post the code you are using to display the result.
|
1 Attachment(s)
Quote:
Heres the code I'm using.. its give me a "Array" as the result. (see attached image) Code:
$result_allweight = $DB_site->query_first(" |
All times are GMT. The time now is 03:09 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|