TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 378
  • Total: 378

Looking for Birthday Code

Started by qwe3, March 17, 2006, 05:59:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rocket

#40
LMAO... ok, I'll make the edit now!   :o :D :buck2:

Sorry JP, I guess I need to pay more attention around here!   :uglystupid2:


manji

Hi,

I have this for my bday block

Quoteglobal $db_prefix, $scripturl;
$last_year = date('U') - (365 * 24 * 60 * 60);$month = date('m');$month_number = '-' . $month . '-';$query = db_query(    "SELECT ID_MEMBER, memberName, birthdate     FROM {$db_prefix}members     WHERE birthdate LIKE '%$month_number%'     AND lastLogin > '$last_year'     ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0){  $birthdays = array();  $member = array();  while ($row = mysql_fetch_assoc($query))  {    $day = substr($row['birthdate'],8,2);    $birthdays[$row['memberName']] =  $day;    $member[$row['memberName']] = $row['ID_MEMBER'];  }  asort($birthdays);  echo '<table>';  $yesterday = 0;  foreach ($birthdays as $key => $value)  {    if ($value <> $yesterday)    {      if ($yesterday > 0)        echo '</td></tr>';      echo '<tr valign="top"><td>' , $value , '</td><td>';    }    echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a>
';    $yesterday = $value;  }  echo '</td></tr></table>';}else  echo 'Não há aniversários este mês';


But today, 01-01-2007, everyone that doesn't have their birthday entered on their profile show up as it's their birthday today ! LOL

Any help on this?

Cheers,
J!

stormlrd

here dont say I never gave yall something  ;D


<?php
global $context$memberContext$settings$options$scripturl$txt$modSettings$user_info$user_profile$sourcedir$db_prefix;
##############################################################Storms holiday Block######################################################
////////////////////user time settings get
$member_name $context['user']['name'];
$request db_query("
SELECT *
FROM 
{$db_prefix}members 
WHERE realName = '
$member_name' "__FILE____LINE__);
        if(
mysql_num_rows($request)>0){
while ($row mysql_fetch_assoc($request))
{
$bday $row['birthdate'];
$qoffset $row['timeOffset'];
$user_time_format $row['timeFormat'];
$memID $row['Full Texts   ID_MEMBER'];
}
mysql_free_result($request);
}
$user_time $context['current_time'];
$user_time_chk strftime ("$user_time_format",time()+$qoffset*3600);

 
////////// BIRTHDAY OVERIDE 

// Split up the birthdate....
list ($uyear$umonth$uday) = explode('-'$bday);
$context['member']['birth_date'] = array(
'year' => $uyear,
'month' => $umonth,
'day' => $uday
);

// Set the age...
if (empty($bday))
{
$context['member'] +=  array(
'age' => &$txt[470],
'today_is_birthday' => false
);
}
else
{
list ($birth_year$birth_month$birth_day) = sscanf($bday'%d-%d-%d');
$datearray getdate(forum_time());
$context['member'] += array(
'age' => $birth_year <= $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}

if(
$context['member']['today_is_birthday']){
  
$birth true
 }
?>



This works correctly I'm currently using it to on a theme Im doing for year round holidays, birthdays, and Daily Default once the themes ready you'll see this code in action

8)

manji

So... I just cram that into a php box? :D

stormlrd

LMAO well you could but it wouldnt show you anything. That doesnt include the echo's to show a birthday plus its setup to check each user as they login on an individual base if you want it too show everyones birthday than you'll have to do some changes but in the case the ssi function would be best, unless you wanting specific member groups and if thats the case look at jp's previous reply as she explains it better than i do and is probably more what your personally looking for.

manji

I guess so.

The thing is that what I posted seem to work perfectly allright... but then it was 1-1-2007 and everyone who didn't set the b-day date shows up on the first day of january :S

stormlrd

part of it is that its not checking for validity. Default bday is jan 1 .

this statement in mine is what checks it

// Set the age...
if (empty($bday))
{
$context['member'] +=  array(
'age' => &$txt[470],
'today_is_birthday' => false
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($bday, '%d-%d-%d');
$datearray = getdate(forum_time());
$context['member'] += array(
'age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}

but you'd have to change it to suite you and your code.

You can kill the jan 1 bdays all together or you can kill jan 1 birthdays where age is 1 lol and that would also work with an if else check

manji

Well, I know nothing of programming so I can't do it :(

Have to wait for JP or could you try and fix it?
It would be your first good dead of the year :P

stormlrd

bad news bro the way your code is laid out its doing a monthly comparision.

Birthdays are in this format in the database 01-01-0001 m d y what your code is doing is pulling out anybodys birthday with todays month period, thats logged in within the last year. to kill the year of the default it really needs to be totally rewritten. I'll take a look see at what i can come up with for you.

This website is proudly hosted on Crocweb Cloud Website Hosting.