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)

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:19 PM.

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.01583 seconds
  • Memory Usage 1,727KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete