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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 318
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 259
  • Total: 259

Greeting Block

Started by rjackson, April 22, 2006, 03:24:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sburke930

I am still not able to get this block working and for the life of me I cannot figure this out.  I have it set as a phpbox, and all I get is a parse error on line 1.  Help, please, someone....Thank you!

<?php
  
global $user_info;

$hour date('G'); 

if(
$hour >= && $hour <= 5

        echo 
'You are up early' $user_info['username'] . '!';
}
else if(
$hour >= && $hour <= 8

        echo 
'Grab your coffee yet' $user_info['username'] . '!';

else if(
$hour <= && $hour <= 12

        echo 
'Good morning' $user_info['username'] . '!';

else if(
$hour >= 13 && $hour <= 16

        echo 
'Good afternoon' $user_info['username'] . '!'

else if(
$hour >= 17 && $hour <= 23

        echo 
'Good evening' $user_info['username'] . '!'


?>

JPDeni

Don't use the

<?php

and

?>

in a php box.

sburke930

OMG...thank you so very very much...I am ecstatic...this block has been bugging me since yesterday morning!

~Play~

JPDeni

:) Glad I could help. It's one of those things that is right there in front of you, but if you don't know about it, you'll never figure it out.

One other little thing you can do, if you want it to reflect the time of day for the user instead of wherever your server is ...

Instead of
$hour = date('G');

use

$hour = date('G') + $user_info['time_offset'];
  if ($hour > 23) { $hour = $hour - 24; }
  elseif ($hour < 0) { $hour = $hour + 24; }

rbh

ok, how do you get this to center inside a block? i am using it inside of a center block, and i want it to be centered within that block rather then set to the left.

JPDeni

After the $hour definition line (whether you have it use the server time or the user's local time) add

echo '<center>';

After the last } add

echo '</center>';


Or, you can use

echo '<span style="text-align:center;">';

and

echo '</span>';

Use whichever flavor you prefer.

rbh


sburke930

Wow so cool...Now I know how to change the font size and color too which was my next question.  Thank you very much for the help.  It is totally appreciated!

JPDeni

You're very welcome. Those <span> tags come in really handy, and are a nice way to ease into using css. :)

sburke930

Houston I have a problem.  the bloc was working perfectly until today.  We installed the karma moed and now I cannot get the block to work at all.  It's just a blank box now.  any suggestions besides the obvious?

This website is proudly hosted on Crocweb Cloud Website Hosting.