PDA

View Full Version : How to? Count of Birthdays on Forum Home


kyrnel
02-16-2004, 12:12 AM
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
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.