Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-10-2002, 07:36 PM
Prince Prince is offline
 
Join Date: Oct 2001
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Do you see any errors in this code?

** the reason I ask is because at 75% it is supposed to display a red image, but it conitnues to display yellow past 75.

PHP Code:
  $inboxpms=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND folderid=0 $ignoreusers");
  if (
$inboxpms 1) {
  
$pmpercent "1"// stop divisions by zero
  
} else {
  
$pmpercent round(($inboxpms[messages] / $pmquota) * 100,2);
  }
  if (
$pmpercent>50) {
  
$barimg="{imagesfolder}/yellow.gif";
  } elseif (
$pmpercent>75) {
  
$barimg="{imagesfolder}/red.gif";
  } else {
  
$barimg="{imagesfolder}/green.gif";
  } 
Reply With Quote
  #2  
Old 07-10-2002, 09:13 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes i see a fault in your code so it is correct:
PHP Code:
$inboxpms=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND folderid=0 $ignoreusers");
  if (
$inboxpms 1) {
  
$pmpercent "1"// stop divisions by zero
  
} else {
  
$pmpercent round(($inboxpms[messages] / $pmquota) * 100,2);
  }
  if (
$pmpercent>50 && $pmpercent<=75) {
  
$barimg="https://vborg.vbsupport.ru/vbimages/yellow.gif";
  } elseif (
$pmpercent>75) {
  
$barimg="https://vborg.vbsupport.ru/vbimages/red.gif";
  } else {
  
$barimg="https://vborg.vbsupport.ru/vbimages/green.gif";
  } 
remember when something is higher than 75 ist also higher than 50
Reply With Quote
  #3  
Old 07-11-2002, 12:03 AM
Prince Prince is offline
 
Join Date: Oct 2001
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I see your logic there, but that screwed up the PM %.
Reply With Quote
  #4  
Old 07-11-2002, 07:53 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

????

can't see a fault, can you explain a bit more?
Reply With Quote
  #5  
Old 07-11-2002, 02:03 PM
Prince Prince is offline
 
Join Date: Oct 2001
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The code tells how full the PM box is based on the max number of PM's allowed.
So, right now I have it set to a max of 75 PM's, and I have 60 PMs total in my PM box, so the % should read 86% full, but when I changed the code it made that % inaccurate, it said something like 40% full.
Reply With Quote
  #6  
Old 07-11-2002, 03:07 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

perhaps you have 60 pms total, but just 30 pms in your inbox?
you just call pms in folderid=0 (inbox-folder) but no sent messages would be inside
Reply With Quote
  #7  
Old 07-11-2002, 04:00 PM
Prince Prince is offline
 
Join Date: Oct 2001
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this code is looking at all folders:

PHP Code:
 $inboxpms=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  if (
$inboxpms 1) {
  
$pmpercent "1"// stop divisions by zero
  
} else {
  
$pmpercent round(($inboxpms[messages] / $pmquota) * 100,2);
  }
  if (
$pmpercent>50) {
  
$barimg="{imagesfolder}/yellow.gif";
  } elseif (
$pmpercent>75) {
  
$barimg="{imagesfolder}/red.gif";
  } else {
  
$barimg="{imagesfolder}/green.gif";
  } 
Reply With Quote
  #8  
Old 07-11-2002, 04:06 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i'd really change the code to that:
PHP Code:
$inboxpms=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$pmpercent=round(($inboxpms[messages] / $pmquota) * 100,2);

  if (
$pmpercent>50 && $pmpercent<=76) {
  
$barimg="https://vborg.vbsupport.ru/vbimages/yellow.gif";
  } else if (
$pmpercent>75) {
  
$barimg="https://vborg.vbsupport.ru/vbimages/red.gif";
  } else {
  
$barimg="https://vborg.vbsupport.ru/vbimages/green.gif";
  } 
no division by zero is possible, because zero is devided by something else, not the other way round...
Reply With Quote
  #9  
Old 07-11-2002, 04:17 PM
Prince Prince is offline
 
Join Date: Oct 2001
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Perfect!

thanks Xenon
Reply With Quote
  #10  
Old 07-11-2002, 04:21 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

np
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:01 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04395 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete