vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vB PHP Counter Script - almost ready (https://vborg.vbsupport.ru/showthread.php?t=175143)

Thomas P 04-04-2008 03:32 PM

vB PHP Counter Script - almost ready
 
Hello,

I use the following script to show a counter in FORUMHOME or wherever I want:
PHP Code:

// ### Counter Hack by J. Schmidt ################################# 
$cquery "SELECT A.title, A.data FROM ".TABLE_PREFIX."datastore AS A WHERE title = 'total_hits' OR title = 'daily_hits'"
$counter $db->query_read($cquery); 
while (
$res $db->fetch_array($counter)) { 
  if(
$res['title'] == "total_hits") { 
    
$total_hits $res['data']; 
  } else if(
$res['title'] == "daily_hits") { 
    
$daily_hits $res['data']; 
  } 

$cquery "UPDATE ".TABLE_PREFIX."datastore SET data = '".++$total_hits."' WHERE title = 'total_hits'"
$counter $db->query_write($cquery); 
$cquery "UPDATE ".TABLE_PREFIX."datastore SET data = '".++$daily_hits."' WHERE title = 'daily_hits'"
$counter $db->query_write($cquery); 
// ### Counter Hack END ################################################# 

Now I just insert $daily_hits into forumhome and I am all set.

Just one thing: The numbers are shown like this: 21458754 without a "." to mark a thousand - how can I change this? :(

Thanks,
-Tom

Opserty 04-04-2008 05:20 PM

$daily_hits = vb_number_format($daily_hits); should do the trick. ;)

Thomas P 04-04-2008 07:50 PM

Hmm, now it get's reset when it reaches 1000 :confused:

The data is stored in the datastore table, which is of type 'mediumtext', if this is any help...

Opserty 04-04-2008 08:19 PM

It only reaches a maximum of 1000 in your datastore table?

Thomas P 04-04-2008 08:58 PM

Only if I place the a.m. code
PHP Code:

$daily_hits vb_number_format($daily_hits); 


Opserty 04-04-2008 09:08 PM

Are you placing that code before or after your update queries?

Thomas P 04-04-2008 09:17 PM

Ah - I see what you mean.

Now I placed the line at the very end and it works like a charm.

Good one - many thanks, that's great :)


All times are GMT. The time now is 05:54 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.01295 seconds
  • Memory Usage 1,729KB
  • 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
  • (7)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