PDA

View Full Version : Good Morning/Good Evening Script



<?PHP>
24-06-2007, 03:57 AM
Hey all, I was bored So i thought i would do some tuts on some scripts.

This One Is Called: Greeting
What It Does: It gives your sites visitors an Alert Box When They Visit your site, saying an appropriate greeting e.g Good Morning If Its Morning
On A Scale Of 1 To 5 How Difficult Is It To Use?:2
What Is The Script Code?:
<!-- START OF SCRIPT -->
<!-- HOW TO INSTALL DAILY GREETING: 1. Copy the coding into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the BODY of your HTML document -->
<BODY>
<SCRIPT LANGUAGE="JavaScript"><!-- Beginvar Today=new Date();var ThisDay=Today.getDay();var ThisDate=Today.getDate();var ThisMonth=Today.getMonth()+1;var ThisYear=Today.getFullYear(); //included if you wish to insert the yearfunction DayTxt
(DayNumber) {var Day=new Array();Day[0]="Sunday";Day[1]="Monday";Day[2]="Tuesday";Day[3]="Wednesday";Day[4]
="Thursday";Day[5]="Friday";Day[6]="Saturday";return Day[DayNumber];}var DayName=DayTxt(ThisDay);function MonthTxt (MonthNumber)
{var Month=new Array();Month[1]="January";Month[2]="February";Month[3]="March";Month[4]="April";Month[5]="May";
Month[6]="June";Month[7]="July";Month[8]="August";Month[9]="September";Month[10]="October";Month[11]="November";Month[12]="December";return Month[MonthNumber];}var MonthName=MonthTxt(ThisMonth);var d = new
Date();var h = d.getHours();document.write("<TABLE BORDER=3 BGCOLOR=WHITE WIDTH=75 HEIGHT=85 align=left>"+"<TD>"+"<p align=center>"+"<font size=-2 >"+DayName+"<br>"+"<font color=orangered size=+3 >"+ThisDate+"</font>"+"<br>"+MonthName+"<br>"+"</b>"+"</font>"+"</p>"+"</TD>"+"</TR>"+"</TABLE>");if (h < 2) document.write("<P ALIGN=center>"+"<b>

<!-Here are the editable greetings:-!>
"+"Good morning! Yes, it's way past midnight."+"</b>"+"</P>");else if (h < 3) document.write("<P ALIGN=center>"+"<b>"+"Good morning! Up early or working late?"+"</b>"+"</P>");else if (h < 7) document.write("<P ALIGN=center>"+"<b>"+"Good morning! Up bright and early!"+"</b>"+"</P>");<-!/////below are the greetings that you can edit-->else if (h < 12) document.write("<P ALIGN=center>"+"<b>"+"Good morning!"+"</b>"+"</P>");else if (h < 17) document.write("<P ALIGN=center>"+"<b>"+"Good afternoon!"+"</b>"+"</P>");else if (h < 23) document.write("<P ALIGN=center>"+"<b>"+"Good evening!"+"</b>"+"</P>");else document.write("<P ALIGN=center>"+"<b>"+"A late good evening! Not much left of it now."+"</b>"+"</P>");// End --></script><!-- END OF SCRIPT -->Need Any Help With The Script PM Me Or email me on [email protected]

Mentor
24-06-2007, 04:15 AM
How does copy and pasteing a poorly written crapy script and writeing what its called, count as writeing a tutorial??

<?PHP>
24-06-2007, 04:18 AM
number 1, it aint a poorly written one
number 2, Not everyone thinks its crappy,
number 3, do u ever say anythin nice?

Drompo
24-06-2007, 09:02 AM
number 1, it aint a poorly written one
number 2, Not everyone thinks its crappy,
number 3, do u ever say anythin nice?

Sorry but 01101101entor is way right.

Next time use the code boxes and explain how its done

Mentor
24-06-2007, 09:08 AM
number 1, it aint a poorly written one Yes it is, VERY poorly written, and that applies to both the code and this tutorial.

number 2, Not everyone thinks its crappy,
What people think is irrelevant, the fact remains it IS crappy.

number 3, do u ever say anythin nice?
Yes, occasional, but only when i actually have something nice to say. I prefer to give my honest opinion, positive or negative. Rather than blankly give a "10/10" to everything which carrys no meaning, like some sort of ******.
If you want "nice" feed back actually do a bit or work and produce something that doesn't suck.

Jamie.
28-06-2007, 08:14 PM
<?php
$q = ($date(H) < 12) ? "morning" : "afternoon";
echo "Good $q!";
?>
Just use that oh by the way yes i got it from techtuts forum because there my friends :) http://www.techtuts.com/forums/index.php?showtopic=804&hl=afternoon

Mentor
28-06-2007, 08:27 PM
<?php
$q = ($date(H) < 12) ? "morning" : "afternoon";
echo "Good $q!";
?>
Just use that oh by the way yes i got it from techtuts forum because there my friends :) http://www.techtuts.com/forums/index.php?showtopic=804&hl=afternoon

I may be wrong but i suspect the $ in front of the date function was added by a accident.

Jamie.
28-06-2007, 08:29 PM
Ye sorry was posting in a rush :D

Mashi
28-06-2007, 08:34 PM
Yeah Becasue he hasn't defined $date (am i right?)

Jamie.
28-06-2007, 08:36 PM
hehe not my php snippet just found on tt so if u read in there yes u will need to define shud of posted but im too tired to bother

Mentor
28-06-2007, 08:44 PM
Yeah Becasue he hasn't defined $date (am i right?)

naa, its because date is a function, not a variable.
The $ sign denotes something as a variable which would mean php would treat it as that instead of a function, meaning the () become invalid and the function doesnt return the data it needs to ether :P

Mashi
29-06-2007, 08:39 PM
"iz nice" Thats what i meant :P

Want to hide these adverts? Register an account for free!