vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to? Count of Birthdays on Forum Home (https://vborg.vbsupport.ru/showthread.php?t=61607)

kyrnel 02-16-2004 12:12 AM

How to? Count of Birthdays on Forum Home
 
Im trying to find the way to do this with the least overhead.
I know I can add some code to index.php to run a query to count the number of birthdays from today, but I'd have to add a number of functions that are redundant of ones in /includes/functions_databuild.php.

Right now the only thing sent to ForumHome is a string value containing all of the current birthdays.
I figure that the only way to get the number of birthdays from the string is to count the commas. Unfortunately I am a bit too new in PHP to fugure this one out.

Is there is a PHP function that counts the number of occurances of one string inside another string?

If not, I will probably have to create a loop that cycles through the string counting the commas (Chr(44)) then add 1 to get the number of birthdays (unless the string is zero-length in which case there are no birthdays).

Any ideas?

Andreas 02-16-2004 12:24 AM

PHP Code:

require_once('./includes/functions_misc.php');
$numbirthdays fetch_character_count($birthdays','); 

But you might get a wrong result if a username contains a comma.
You could also count for '<a href="member.php?u' - I really doubt somebody would have this string in his username ;)

IMHO the best solution would be to modify build_birthdays() to also put the number into cache. This way there would be zero overhead when displaying.
I'll post more details for this in a few minutes.

Update:
https://vborg.vbsupport.ru/showthread.php?t=61610

kyrnel 02-16-2004 02:02 AM

Sweet! Thank you very much.


All times are GMT. The time now is 04:13 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.02592 seconds
  • Memory Usage 1,719KB
  • 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)post_thanks_navbar_search
  • (1)printthread
  • (3)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