vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help! (https://vborg.vbsupport.ru/showthread.php?t=46792)

chad777 12-19-2002 01:03 AM

Help!
 
ok this is want i am trying to do.

I have added an extra field to the user table called amtdonation.

what I want to do is make a page that will display the members with the highest amtdonation

Example:

user 1 has 10.00
user 2 has 20.00
and
user 3 has 5.00

what I want to generate is a page that has

1. user 2 20.00
2. User 1 10.00
3. User 3 5.00

Total amount = 35.00

a top list of donators

it would be display like username in one cell and donation in second field

then the total at the buttom

can anyone make this or tell me where to start by giving me some sample code ?

Thanks

GSHelpBoy 12-19-2002 01:05 AM

PHP Code:

$sql 'SELECT `user`, `amount`, SUM(`amount`) FROM `donation` ORDER BY `amount`'

That would select the user, the amount donated by that user, and the sum of all the donations.

Erwin 12-19-2002 02:35 AM

Hi, GSHelpBoy,

Just a friendly reminder - to download hacks and get support you will need to go to this page and enter your email address, to show you are licensed. (you will need to use your customer number and password to access that page)

Thank you. :)

chad777 12-19-2002 02:23 PM

maybe I better redo this question.

using vb's global tag at the top
what would I have to do to display like I said before ?

DrkFusion 12-19-2002 10:57 PM

Umm u mean vB's

$DB_site-> ??

chad777 12-19-2002 11:24 PM

No the whole code on what i would need ;)

DrkFusion 12-20-2002 12:51 AM

Umm you mean

[sql]$DB_site->query("'SELECT `user`, `amount`, SUM(`amount`) FROM `donation` ORDER BY `amount`');[/sql]

??? Sorry, but you are not being clearn on what you which to accomplish here.

chad777 12-20-2002 10:03 AM

yeah like that but how would I display the output of it into tables to be like a top 10 list ?

DrkFusion 12-20-2002 12:18 PM

You would loop it...in like for instance using a while(), your file archive hack seems to use it...err well of course it does, because the code is from mine :-p....just check out your err file hack, and you will see how to do it.

chad777 12-20-2002 12:30 PM

my file file archive hack ? I didn't make one ?

GSHelpBoy 12-20-2002 07:27 PM

Use this code:
PHP Code:

<?php
$query 
$DB_site->query('SELECT `user`, `amount`, SUM(`amount`) AS `total` FROM `donation` ORDER BY `amount` DESC LIMIT 10');

print(
'<table>');
print(
'<tr><th>User</th><th>Donation</th></tr>');
while (
$row $DB_site->fetch_array($query)) {
    print(
'<tr><td>' $row['user'] . '</td><td>' $row['amount'] . '</td></tr>');
}
print(
'<tr><th colspan="2">Total: ' $row['total'] . '</th></tr>');
print(
'</table>');
?>

See how that does.

chad777 12-20-2002 07:34 PM

I think that will work great... i haven't tried yet.

Will that order the users from 1-10 by total amount of user then sum the total of all of them at the buttom?


btw thanks for the code :)

chad777 12-20-2002 08:10 PM

nope didn't work giving this error

Invalid SQL: SELECT `user`, `amount`, SUM(`amount`) AS `total` FROM `donation` ORDER BY `amount` DESC LIMIT 10

mysql error: Table 'forum.donation' doesn't exist

i have the amount in the user table under field amount?

GSHelpBoy 12-20-2002 09:49 PM

I thought you already had the donation table created...

chad777 12-20-2002 10:14 PM

no i just have a field under the table user called amount which is where I put the amount of the donation.
?

DrkFusion 12-20-2002 10:45 PM

Umm the archive hack of which the structure for was taken from my hack. Anyways

DrkFusion 12-20-2002 10:56 PM

Any hoo, though I am 100% sure it was you, you posted this thread to get help, so it doesn't matter anyways.

chad777 12-21-2002 12:29 AM

I never did a file achieve hack...i think you are thinking of someone else ?

chad777 12-24-2002 12:07 PM

but anyways going back to that script..

I made the donations table with fields (user, amount)

it now displays them in a list but it don't sort them or sum the amounts for each user and put them into a top 10.

also the total amount at the buttom don't work.

I have to change ORDER BY to GROUP BY or i got an error

Invalid SQL: SELECT `user`, `amount`, SUM(`amount`) AS `total` FROM `donation` ORDER BY `amount` DESC LIMIT 10 mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause


:(


All times are GMT. The time now is 02:10 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
  • Page Generation 0.01111 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete