Page Style and Background Manager with Hour

Written by @m_k_amin 23 December 2012

This script let you manage the page background and style based on the hour of the day. All of the texts and tables are set automatically base on the hour. It also has capability to define a style (here 'Cheetah') and manage all the things based on that. You can make your page more beautiful and suitable with the users by this script; Enjoy!

Code Snippet:

                                                
                                                <!-- this script is provided by www.phpfreecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.hawkee.com, found at www.phpfreecode.com-->
<?php
//$type='cheetah';
$type="hour";
$h=date("H");
function Bg(){
global $type,$h;
	switch ($type){
		case 'cheetah':
			return "background='cheetah.png'";
			break;	
		case 'hour':
			if ($h<11)
				$color='#CCFFFF';
			elseif ($h>11 && $h<17)
				$color='#FFFFCC';
			else
				$color='#CCCCCC';
			return "bgcolor=$color";
	}

}

?>

<head>
<style type="text/css">
<?php 
switch ($type){
	case 'cheetah':
		$c1='#F8E3E3';
		$c2='#FFFFFF';
		$c3='#CCFFFF';
		$c4='#F5F5B9';
		$c5='#F5F5B9';
		break;
	case 'hour':
		if ($h<11){
			$c1='#0B2880';
			$c2='#008080';
			$c3='#663300';
			$c4='#FFEAEA';
			$c5='#80320B';
		}elseif ($h>11 && $h<17){
			$c1='#0B2880';
			$c2='#008080';
			$c3='#663300';
			$c4='#FFEAEA';
			$c5='#80320B';
		}else{
			$c1='#7B074F';
			$c2='#008080';
			$c3='#808000';
			$c4='#DDFFDD';
			$c5='#2E04E1';
		}	
}
echo"
p{
	font-size: 14pt; color:$c1 }
table {
	border: 1px solid $c2}
td{
	border: 1px solid $c3 ; background-color: $c4}
h1{
	color: $c5}
";

?>	
</style>
</head>

<body <?php echo Bg() ?> >
<h1 style="text-align: center">Heading 1</h1>
<p style="text-align: center">This is a paragraph.</p>
<table align="center" style="height: 64px; width: 93px">
	<tr>
		<td style="width: 45px; height: 32px">1</td>
		<td style="width: 46px; height: 32px">2</td>
	</tr>
	<tr>
		<td style="width: 45px; height: 32px">1</td>
		<td style="width: 46px; height: 32px">2</td>
	</tr>
</table>
</body>

<br><div style="text-align: center; height: 15px">
	<font face="Tahoma"><a target="_blank" href="http://www.phpfreecode.com/">
	<span style="font-size: 8pt; text-decoration: none; color: #7B074F; background-color: #FFFF00;">PHP Free Code</span></a></font></div><a target='_blank' href='www.phpfreecode.com' style='font-size: 8pt; text-decoration: none'>Php Best Codes</a>                                                
                                            

Example:


About @m_k_amin

This user is pending a biography.

M

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: grkkid, Manaakividuinfo.com, karticksv, sava, tinatina
advertisement 2