School Map:  Home / Enroll $ Student Records; Class  
$ News @ LIVE Tech Radio * Support/FAQ | Store | FORUMS

 

 (#227 2003-09-17 05:19:04) Post Reply
Page 0 1 2 3 4 5

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

marcus, first you need to set two variables for your script to work, one is the one you already have: $_today=date("w"); and the other is like this: $_today2=date("l"); <-- lowercase "L"

now on the day strings you should change the $_today to $_today2 so it prints the name of the day instead of the number of the day like so: $_sun0="$_today2 s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>."; and so on for the rest of them

next there's another error, you need to quote the value after the case condition: case "0":

so your code should come out something like this:


<html>
<head>
<title>Week #2 Basic - Link a Day</title>
<body>
<center>Week #2 Basic - Link a Day</center>
<br>
<?php

$_today
=date("w");//sets date
$_today2="date("l");

//Following are values for days
$_sun0="
$_today2 s Link is to <a href=

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /web/sites/tdavid/non_public_system/parsemsg.php on line 94

"http://www.fagfrat.com/photos\">Photo Page</a>.";
$_mon1="$_today2 s Link is to <a href=\"http://www.fagfrat.com/members\">Members Page</a>.";
$_tue2="$_today2 s Link is to <a href=\"http://www.fagfrat.com/calendar\">Calendar Page</a>.";
$_wed3="$_today2 s Link is to <a href=\"http://www.fagfrat.com\">Mainpage Page</a>.";
$_thu4="$_today2 s Link is to <a href=\"http://www.fagfrat.com#parties\">Parties Page</a>.";
$_fri5="$_today2 s Link is to <a href=\"http://www.fagfrat.com#royal\">Royal Page</a>.";
$_sat6="$_today2 s Link is to <a href=\"http://www.fagfrat.com#synergy\">Synergy Page</a>.";

switch(
$_today)
{
case
"0":
print(
$_sun0);// it is true so do this
break; // escape the switch since we had a true result

case "1":
print(
$_mon1);
break;

case
"2":
print(
$_tue2);
break;

case
"3":
print(
$_wed3);
break;

case
"4":
print(
$_thu4);
break;

case
"5":
print(
$_fri5);
break;

case
"6":
print(
$_sat6);
break;

default:
print(
"Today does not exist, time is over. Hello");// when nothing is true do this
}

?>
</body>
</html>



also please dont forget to also post an url link to a copy of the script from now on, they're gonna get a lil bit more complicated and we cant just see the code to correct it, no one's that good :)

 

 (#228 2003-09-17 05:22:05) Post Reply
Page 0 1 2 3 4 5

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

oops, sorry :P, somethin like this:


<html>
<head>
<title>Week #2 Basic - Link a Day</title>
<body>
<center>Week #2 Basic - Link a Day</center>
<br>
<?php

$_today
=date("w");//sets date
$_today2=date("l");

//Following are values for days
$_sun0="$_today2 s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>.";
$_mon1="$_today2 s Link is to <a href=\"http://www.fagfrat.com/members\">Members Page</a>.";
$_tue2="$_today2 s Link is to <a href=\"http://www.fagfrat.com/calendar\">Calendar Page</a>.";
$_wed3="$_today2 s Link is to <a href=\"http://www.fagfrat.com\">Mainpage Page</a>.";
$_thu4="$_today2 s Link is to <a href=\"http://www.fagfrat.com#parties\">Parties Page</a>.";
$_fri5="$_today2 s Link is to <a href=\"http://www.fagfrat.com#royal\">Royal Page</a>.";
$_sat6="$_today2 s Link is to <a href=\"http://www.fagfrat.com#synergy\">Synergy Page</a>.";

switch(
$_today)
{
case
"0":
print(
$_sun0);// it is true so do this
break; // escape the switch since we had a true result

case "1":
print(
$_mon1);
break;

case
"2":
print(
$_tue2);
break;

case
"3":
print(
$_wed3);
break;

case
"4":
print(
$_thu4);
break;

case
"5":
print(
$_fri5);
break;

case
"6":
print(
$_sat6);
break;

default:
print(
"Today does not exist, time is over. Hello");// when nothing is true do this
}

?>
</body>
</html>


 

 (#245 2003-09-18 05:51:13) Post Reply
Page 0 1 2 3 4 5

MarcusD79
Need To Set


Enrolled: Sep 2003
Posts: 10
AP: 1

Thanks Quicksaver, I made the adjustments but it does not seem to work. Well, that is part true, the .php now works. There seems to be a problem with the html and php working together. After getting the php to work I realized I had forgoten </head>, but it turns out to not have been the problem. I have also found that case 0: does not need to be case "0"; to work. Well here is a link to the working php: http://www.fagfrat.com/phpclass/week2a.php
and here is one to the not working php in html: http://www.fagfrat.com/phpclass/week2a.html

The problem seems to be here in this line:
$_sun0="$_today2 s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>.";

Well here is my whole code again.



<html>
<head>
<title>Week #2 Basic - Link a Day</title>
</head>

<body>
<center>Week #2 Basic - Link a Day</center>
<br>
<?php

$_today
=date("w");//sets date
$_today2=date("l");

//Following are values for days
$_sun0="$_today2 s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>.";
$_mon1="$_today2 s Link is to <a href=\"http://www.fagfrat.com/members\">Members Page</a>.";
$_tue2="$_today2 s Link is to <a href=\"http://www.fagfrat.com/calendar\">Calendar Page</a>.";
$_wed3="$_today2 s Link is to <a href=\"http://www.fagfrat.com\">Mainpage Page</a>.";
$_thu4="$_today2 s Link is to <a href=\"http://www.fagfrat.com#parties\">Parties Page</a>.";
$_fri5="$_today2 s Link is to <a href=\"http://www.fagfrat.com#royal\">Royal Page</a>.";
$_sat6="$_today2 s Link is to <a href=\"http://www.fagfrat.com#synergy\">Synergy Page</a>.";

switch(
$_today)
{
case
0:
print(
$_sun0);// it is true so do this
break; // escape the switch since we had a true result

case 1:
print(
$_mon1);
break;

case
2:
print(
$_tue2);
break;

case
3:
print(
$_wed3);
break;

case
4:
print(
$_thu4);
break;

case
5:
print(
$_fri5);
break;

case
6:
print(
$_sat6);
break;

default:
print(
"Today does not exist, time is over. Hello");// when nothing is true do this
}

?>

</body>
</html>



 

 (#247 2003-09-18 08:35:01) Post Reply
Page 0 1 2 3 4 5

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

Marcus, I have tried your scripts.
When I copied the whole scripts to a file named temp.html. It has error.

But when I rename the file to temp.php.
It works fine and give accurate result.

Hope this help u.

 

 (#248 2003-09-18 09:31:48) Post Reply
Page 0 1 2 3 4 5

MarcusD79
Need To Set


Enrolled: Sep 2003
Posts: 10
AP: 1

Shrek, was it really that simple? I had assumed that since we were putting php in html then it was to be a html file. DOH. Well, thanks for your help, I also have it working and have kicked myself.

 

 (#250 2003-09-19 11:00:48) Post Reply
Page 0 1 2 3 4 5

amiller
Need To Set


Enrolled: Sep 2003
Posts: 2
AP: 1

<TITLE>2</TITLE>
<center>

<?php

$today=date("w");
$comment="todays link is: ";


switch($today)
{
case "0":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "1":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "2":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "3":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "4":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "5":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;
case "6":$url = "<a href=\"http://www.google.com\">Google</a><br>Google search engine"; break;


}
print $comment . $url;
?>

 

 (#252 2003-09-19 17:07:46) Post Reply
Page 0 1 2 3 4 5

merlin69
Need To Set


Enrolled: Sep 2003
Posts: 4
AP: 1



<html>
<head>
<title>Week 2 assignment</title>
</head>
<body>
<?php
// this script is designed to show a different url for each day of the week
// by using a call to function and print statementts using the $string variable
$today = date("w");// calling date
$desc = "link of the day";
// call variables
$sunlink = "<a href=http://www.knick-nacks.com>knick-nacks.com</a>";
$sundesc = "<br>a site I like to visit";
$monlink = "<a href=http://members.knick-nacks.com>members@knick-nacks.com</a>";
$mondesc = "<br>members only site for a favorite place to visit";
$tueslink = "<a href=http://www.realm-of-merlin.com/school/firstscript.php>first assignment</a>";
$tuesdesc = "<br>My first assignment for script school";
$wedlink = "<a href=http://www.realm-of-merlin.com/school/week_one_extended.php>first assignment advanced</a>";
$weddesc = "<br>my first script for script school with a few modifications";
$thurslink = "<a href=http://www.realm-of-merlin.com/>Realm of Merlin</a>";
$thursdesc = "<br>Realm of Merlinl, I know no promoting but this page is underconstruction";
$frilink = "<a href=http://www.ebay.com/>ebay</a>";
$fridesc = "<br><font=red> I think this site says it all. Welcome to</font><font=blue><b> ebay<b></font>";
$satlink = "<a href=http://www.yahoo.com/>Yahoo</a>";
$satdesc = "<br>yahoo, the best free email on the net";
// end of call variables
// now we will call the functions to switch the dates
// internally and display the link for that day
Print("Hello today is&nbsp;".date("l F j, Y"));
print(
"<br>I would Like to share my favorite site &nbsp;");

switch(
$today)

{
case
0:
print(
$sunlink);// it is true so do this
print($sundesc);
break;
// escape the switch since we had a true result

case 1:
print(
$monlink);
print(
$mondesc);
break;

case
2:
print(
$tueslink);
print(
$tuesdesc);
break;

case
3:
print(
$wedlink);
print(
$weddesc);
break;

case
4:
print(
$thurslink);
print(
$thursdesc);
break;

case
5:
print(
$frilink);
print(
$fridesc);
break;

case
6:
print(
$satlink);
print(
$satdesc);
break;


}

?>





I have a working demo <a href="http://www.realm-of-merlin.com/school/week2.php">Click here</a>

 

 (#318 2003-10-14 00:44:47) Post Reply
Page 0 1 2 3 4 5

canadian
Need To Set


Enrolled: Oct 2003
Posts: 1
AP: 1

ive check and double checked but i still can't find what wrong, the error is on line 11.


<html>
<head>
<title>Week 2 For PHP Learning Course: Assignment 2</title>
</head>
<body>
<?
$today = ("w");

switch($today) {
case "0":
$url = "<a href= "http://www.Sunday.com">Sunday</a>";
$des = "It's Sunday";
break;
case "1":
$url = "<a href= "http://www.Monday.com">Monday</a>";
$des = "It's Monday";
break;
case "2":
$url = "<a href= "http://www.tuesday.com">tuesday</a>";
$des = "It's tuesday";
break;
case "3":
$url = "<a href= "http://www.wednesday.com">wednesday</a>";
$des = "It's wednesday";
break;
case "4":
$url = "<a href= "http://www.thursday.com">Thursday</a>";
$des = "It's Thursday";
break;
case "5":
$url = "<a href= "http://www.Friday.com">Friday</a>";
$des = "It's Friday";
break;
case "6":
$url = "<a href= "http://www.saturday.com">Saturday</a>";
$des = "It's Saturday";
break;
default:
$url = "No URL";
$des = "No description"; }

print("$today, $url,$des");
?>
</body>
</html>

 

 (#320 2003-10-14 09:44:27) Post Reply
Page 0 1 2 3 4 5

jennyjlo
Need To Set


Enrolled: Oct 2003
Posts: 2
AP: 1

I think I got it!!!!!


<HTML>
<HEAD>
<TITLE>SchoolScript.com Assignment 2 - URL of the Day</TITLE>
</HEAD>
<BODY>
<?php
// This program will use the switch function to display a different url each day.
// Get the numerical day of the week and assign it to a variable
$today = date("w");
// Assign urls and descriptions to variables.
$onelink = "<A HREF = <A HREF="http://www.jeneration-designs.com</A>";" TARGET=_blank>http://www.jeneration-designs....om</A>";</A>
$onelinkdesc = "Jeneration-Designs Web Designs and Producion";
$twolink = "<A HREF = <A HREF="http://www.county.simcoe.on.ca></A>";" TARGET=_blank>http://www.county.simcoe.on.ca...t;</A>";</A>
$twolinkdesc = "County of Simcoe";
$threelink = "<A HREF = <A HREF="http://www.scdsb.on.ca></A>";" TARGET=_blank>http://www.scdsb.on.ca></A>";</A>
$threelinkdesc = "Simcoe County District School Board";
$fourlink = "<A HREF = <A HREF="http://www.simply-perfect.cam></A>";" TARGET=_blank>http://www.simply-perfect.cam&...t;</A>";</A>
$fourlinkdesc = "Simply Perfect";
$fivelink = "<A HREF = <A HREF="http://www.springwater.ca</A>";" TARGET=_blank>http://www.springwater.ca</A>";</A>
$fivelinkdesc = "Township of Springwater";
$sixlink = "<A HREF = <A HREF="http://www.ebay.com></A>";" TARGET=_blank>http://www.ebay.com></A>";</A>
$sixlinkdesc = "ebay";
$sevenlink = "<A HREF = <A HREF="http://www.fastwebsites.com</A>";" TARGET=_blank>http://www.fastwebsites.com</A>";</A>
$sevenlinkdesc = "Fast Web Sites web hosting";
// SWITCH
switch ($today) {
case
0:
print (
"Today's link is: " . $onelink<br> . $onelinkdesc);
break;
case
1:
print (
"Today's link is: " . $twolink<br> . $twolinkdesc);
break;
case
2:
print (
"Today's link is: " . $threelink<br> . $threelinkdesc);
break;
case
3:
print (
"Today's link is: " . $fourlink<br> . $fourlinkdesc);
break;
case
4:
print (
"Today's link is: " . $fivelink<br> . $fivelinkdesc);
break;
case
5:
print (
"Today's link is: " . $sixlink<br> . $sixlinkdesc);
break;
default:
print (
"Today's link is: " . $sevenlink<br> . $sevenlinkdesc);

?>
</BODY>
</HTML>


 

 (#330 2003-10-24 20:44:16) Post Reply
Page 0 1 2 3 4 5

willie565
Need To Set


Enrolled: Oct 2003
Posts: 5
AP: 1

It Works Perfectly And Only took about 10 minutes to make but noneless I wanted to post it here


<html>
<?php
$dayweek
= date("w");
echo(
"The Current Date is: ".date("j/n/y")."<br>");
switch(
$dayweek)
{
case
"0":
$turl="Todays link is <a href='http://www.yahoo.com'>Yahoo</a>";
$action = 1;
break;
case
"1":
$turl="Todays link is <a href='http://www.google.com'>Google</a>";
$action = 1;
break;
case
"2":
$turl="Todays link is <a href='http://www.scriptschool.com'>Script School</a>";
$action = 1;
break;
case
"3":
$turl="Todays link is <a href='http://www.megatech.tk'>MegaTech</a>";
$action = 1;
break;
case
"4":
$turl="Todays link is <a href='http://www.newgrounds.com'>NewGrounds</a>";
$action = 1;
break;
case
"5":
$turl="Todays link is <a href='http://www.draac.com'>Draac</a>";
$action = 1;
break;
case
"6":
$turl="Todays link is <a href='http://www.fooble.com'>Fooble</a>";
$action = 1;
break;
default:
echo(
"Error");
}
if(
$action == 1){
echo(
"$turl");
}
?>
</html>


 

 (#349 2003-10-31 11:40:44) Post Reply
Page 0 1 2 3 4 5

Dest
Need To Set


Enrolled: Oct 2003
Posts: 18
AP: 1

Hi all. i made this one only after look in to other works. i need it only to understand swich function. and i am confused about brackets. but anyway. about switch is clear now :) here's my script:




<?
//Our date string:
$date=date("w");
$date2=date("l");

//Swich... setting strigs
switch($date)
{
case
"1":
$site="<a href=http://www.google.com>Google</a>";
$desc="Fantastic search engine";
break;

case
"2":
$site="<a href=http://www.nba.com>NBA</a>";
$desc="National Basketball Association";
break;

case
"3":
$site="<a href=>http://www.delfi.lt</a>";
$desc="Lithuanian news site";
break;

case
"4":
$site="<a href=http://www.scriptschool.com/php/>Script School</a>";
$desc="The best place to learn PHP scripting";
break;

case
"5":
$site="<a href=http://www.galaxiesablaze.com>Galaxies Ablaze</a>";
$desc="Very nice online game";
break;

case
"6":
$site="<a href=http://www.cartoonnetwork.com>Cartoon Network</a>";
$desc="No comments :) You must visit it :-)";
break;

case
"0":
$site="<a href=http://www.elastomania.com>ElastoMania</a>";
$desc="Great 2d game. download demo here...";
break;

}
print(
"Hi. Today is $date2 and todays site is: <br><br> $site <br> $desc")

?>




And working example: http://tts.lt/~sir/scripts/week2.php

 

 (#354 2003-11-03 02:12:09) Post Reply
Page 0 1 2 3 4 5

CyberAce
Need To Set


Enrolled: Nov 2003
Posts: 1
AP: 1

Helo I just signed up so I am catching up to were I should be. Here is my code for week 2.
[CODE]
<?
$today = date("w");
$title = "Scriptschool Assignement 2:";

$sunday = "http://www.lvrocks.com";
$monday = "http://www.scriptschool.com";
$tuesday = "http://www.tdscripts.com";
$wednesday = "http://www.theadultwebmaster.com";
$thursday = "http://www.adultnetsurprise.com";
$friday = "http://www.ebay.com";
$saturday = "http://www.cybersorcerer.vzz.net";
?>
<html>
<head>
<title><? echo $title ?></title>
</head>
<body>
<?
switch ($today)
{
case 0:
print("<a href=".$sunday.">".$sunday."</a>");
break;
case 1:
print("<a href=".$monday.">".$monday."</a>");
break;
case 2:
print("<a href=".$tuesday.">".$tuesday."</a>");
break;
case 3:
print("<a href=".$wednesday.">".$wednesday."</a>");
break;
case 4:
print("<a href=".$thursday.">".$thursday."</a>");
break;
case 5:
print("<a href=".$friday.">".$friday."</a>");
break;
default:
print("<a href=".$saturday.">".$saturday."</a>");
}
?>
</body>
</html>
[/CODE]

I got it working with just 2 retries.

 

 (#377 2003-11-16 07:47:55) Post Reply
Page 0 1 2 3 4 5

Ahkorahil
Need To Set


Enrolled: Oct 2003
Posts: 20
AP: 1

<HTML>
<HEAD>
<TITLE> MY home assignment 2 </TITLE>
</HEAD>
<BODY>
<?php
// This is the switch function to display in each day different URL
$today = date("w");
$monlink= "<A HREF = http://www.hot.ee/>";
$mondesc= "hoti kodukas";
$tuelink= "<A HREF =http://www.neti.ee/>";
$tuedesc= "neti lehekülg";
$wednlink= "<A HREF=http://www.jippii.ee/>" ;
$wednlink= "jippii!";
$thulink= "<A HREF=http://www.scriptschool.com/>";
$thudesc= "scriptschool";
$frilink= "<A HREF=http://www.zone.ee/kincclan/>" ;
$fridesc= "<b> My clan site.</b> Made by me.";
$satlink= "<A HREF=http://www.zone.ee/>";
$satdesc= "<b>Zone</b> site";
$sunlink= "<A HREF=http://www.gameland.ee/>" ;
$sundesc= "<font face=Monotype Corsiva> Gameland </font>;
//SWITCH
switch($today) {
case 0:
print("Today's link is: .$monlink .$monlink");
break;
case 1:
printf("Today's link is: .$tuelink<br> .$tuedesc");
break
case 2:
print("Today's link is: .$wednlink<br> .$wedndesc");
case 3:
print("Today's link is: .$thulink<br> .$thudesc");
case 4:
print("Today's link is: .$frilink<br> .$fridesc");
case 5:
printf("today's link is: .$satlink<br> .$satdesc");
default:
printf("Today's link is .$sunlink<br> .$sundesc");
}
?>
</BODY>
</HTML>

 

 (#379 2003-11-16 18:06:25) Post Reply
Page 0 1 2 3 4 5

coinweb
Need To Set


Enrolled: Nov 2003
Posts: 4
AP: 1

<html>
<head>
<TITLE>Homework For Week #2</TITLE>
</head>
<body bgcolor="blue">

<center><table width="60%" border="1" bgcolor="white">
<br><br><br><br><br><br>
<tr>
<td>

<?php
/*TO-DO ASSIGNMENT #2: Write a script to print to the browser a different URL each day
of the week using the switch/case statement and comparing to the numeric day of the
week (0-6), not the textual (Sunday-Saturday) day of the week.

Use only one print() function to do this and make these urls active hyperlinks
with the url title hyperlinked and the url description not hyperlinked.

Employ the use of concatenation to create the single print function instead of
enclosing in interpreted double quotes to demonstrate your understanding of
concatenating strings.
*/

$today =date("w");

$comment = "Please visit this link today:";


//The Switch

switch($today)
{
case "0";
$url = " <a href=\"http://www.ebay.com\">http://www.ebay.com</a><br><br><b>Checkout some auctions this nice quiet Sunday afternoon</b>";
break;
case "1";
$url = " <a href=\"http://www.coinwebstore.com/\">http://www.coinwebstore.com</a><br><br><b>Purchase some rare coins to help you get through this manic monday</b>";
break;
case "2";
$url = " <a href=\"http://www.google.com/\">http://www.google.com</a><br><br><b>Searching on Tuesdays is never easier than with Google</b>";
break;
case "3";
$url = " <a href=\"http://www.humpback.com\">http://www.humpback.com</a><br><br><b>What better place to visit on Wednesday (Hump Day)</b>";
break;
case "4";
$url = " <a href=\"http://www.thursday.com\">http://www.thursday.com</a><br><br><b>What more can you say? it's Thursday!</b>";
break;
case "5";
$url = " <a href=\"http://www.millerbrewing.com\">http://www.millerbrewing.com</a><br><br><b>Friday Night !! It's Miller time.</b>";
break;
case "6";
$url = " <a href=\"http://www.teetool.com\">http://www.teetool.com</a><br><br><b>Need a cool golf tool for your Saturday round?</b>";
break;
}

print($comment . $url);

?>

</td>
</tr>
</table>
</body>
</html>

 

 (#384 2003-11-17 13:30:38) Post Reply
Page 0 1 2 3 4 5

RamblnRick
Need To Set


Enrolled: Nov 2003
Posts: 6
AP: 1

I think this is right. Still trying to get the code to print correctly in the forum. There was mention of a colorize box to be checked that I do not see.


<html>
<head>
<title>Week Number 2 Basic - Link Of The Day</title>
<body>


<?php

// This script will display a different link for each day using the switch/case function and print statements
// with variables

// Assign variables
$_today=date("w");// Sets the date
$_day=date("l");
$_date=date("n/j/y");

switch(
$_today)
{
case
"0":// if true do this
$_site="<a href=http://www.scriptschool.com>ScriptSchool";
break;
// escape the switch with a true result

case "1":
$_site="<a href=http://www.yahoo.com>Yahoo";
break;

case
"2":
$_site="<a href=http://www.google.com>Google";
break;

case
"3":
$_site="<a href=http://www.msn.com>MSN";
break;

case
"4":
$_site="<a href=http://www.hotmail.com>Hotmail";
break;

case
"5":
$_site="<a href=http://www.tdscripts.com>TD Scripts";
break;

case
"6":
$_site="<a href=http://www.cardplayer.com>CardPlayer";
break;

default:
print(
"Yikes! Now, where is that back button"); // When nothing is true do this
break;
}
print(
"The link for $_day $_date is $_site");
?>



</body>
</html>

Working script at http://www.ricksramblings.com/..._assignment.php

 

 (#385 2003-11-17 13:33:50) Post Reply
Page 0 1 2 3 4 5

RamblnRick
Need To Set


Enrolled: Nov 2003
Posts: 6
AP: 1

The correct URL for the worrking script above is http://www.ricksramblings.com/..._assignment.php

 

 (#397 2003-11-21 18:18:44) Post Reply
Page 0 1 2 3 4 5

hatiangeek
Need To Set


Enrolled: Nov 2003
Posts: 2
AP: 1

<script language="php">
// This script will out a different active URL based on the day of the week using
// the date php function and the switch structure

$currentDate=date(w);
$Sunday="<a href="http://www.Sakapfet.com">http://www.Sakapfet.com</a>";
$Monday="<a href="http://www.akolad.com">Akolad.com</a>";
$Sunday="<a href="http://www.expresswebsite.com">eXpressWebsite.com</a>";
$Tuesday="<a href="http://www.fouye.com">http://www.fouye.com</a>";
$Wenesday="<a href="http://www.yahoo.com">http://www.yahoo.com</a>";
$Thursday="<a href="http://www.everythinghaitian.com">http://www.everythinghaitian.com</a>";
$Friday="<a href="http://www.haitiexchange.com">http://www.haitiexchange.com.com</a>";
$Saturday="<a href="http://www.baltimoredestmarc.com">http://www.baltimoredestmarc.com</a>";

switch($currentDate)
{
case 0:
print("The site of the day is: ".$Sunday);
break;
case 1:
print("The site of the day is: ".$Monday);
break;
case 2:
print("The site of the day is: ".$Tuesday);
break;
case 3:
print("The site of the day is: ".$Wenesday);
break;
case 4:
print("The site of the day is: ".$Thursday);
break;
case 5:
print("The site of the day is: ".$Friday);
break;
case 6:
print("The site of the day is: ".$Saturday);

break;





}


</script>

 

 (#408 2003-11-29 20:29:18) Post Reply
Page 0 1 2 3 4 5

DJRemiasz
Need To Set


Enrolled: Nov 2003
Posts: 3
AP: 1

<?
$today = date("l");
if ($today == "Sunday")
{
print ("<img src=\"\profile.gif\">");
}
if ($today == "Friday")
{
print ("<img src=\"\pencil.gif\">");
}
?>

 

 (#409 2003-11-29 20:30:52) Post Reply
Page 0 1 2 3 4 5

DJRemiasz
Need To Set


Enrolled: Nov 2003
Posts: 3
AP: 1

Oops! Sorry this is it:
<?
$today = date("l");
if ($today == "Sunday")
{
print ("<img src=\"image0.jpg\">");
}
if ($today == "Monday")
{
print ("<img src=\"image1.jpg\">");
}
if ($today == "Tuesday")
{
print ("<img src=\"image2.jpg\">");
}
if ($today == "Wednesday")
{
print ("<img src=\"image3.jpg\">");
}
if ($today == "Thursday")
{
print ("<img src=\"image4.jpg\">");
}
if ($today == "Friday")
{
print ("<img src=\"image5.jpg\">");
}
if ($today == "Saturday")
{
print ("<img src=\"image6.jpg\">");
}
?>

 

 (#414 2003-12-10 23:23:25) Post Reply
Page 0 1 2 3 4 5

fudded
Need To Set


Enrolled: Dec 2003
Posts: 5
AP: 1



<html>
<head>
<title>Lesson Two</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<center>
<?php
// seven URL's for each day of the week
$url_0 = '<a href = <A HREF="http://www.google.com>" TARGET=_blank>http://www.google.com></A> www.google.com </a>';
$url_1 = '<a href = <A HREF="http://www.lycos.co.uk>" TARGET=_blank>http://www.lycos.co.uk></A> www.lycos.co.uk </a>';
$url_2 = '<a href = <A HREF="http://www.yahoo.com>" TARGET=_blank>http://www.yahoo.com></A> www.yahoo.com </a>';
$url_3 = '<a href = <A HREF="http://www.askjeeves.com>" TARGET=_blank>http://www.askjeeves.com></A> www.askjeeves.com </a>';
$url_4 = '<a href = <A HREF="http://www.britishcanday.com>" TARGET=_blank>http://www.britishcanday.com></A> www.britishcanday.com </a>';
$url_5 = '<a href = <A HREF="http://www.friendsreunited.com>" TARGET=_blank>http://www.friendsreunited.com></A> www.friendsreunited.com </a>';
$url_6 = '<a href = <A HREF="http://www.rotten.com>" TARGET=_blank>http://www.rotten.com></A> www.rotten.com </a>';

// URL descriptions
$url0_desc = 'the answer to life, love and the universe';
$url1_desc = 'another good search engine, & free sms service ';
$url2_desc = 'search engine also offers email';
$url3_desc = ' a UK search engine';
$url4_desc = 'A friends website selling sweets';
$url5_desc = 'Meet old school friends';
$url6_desc = 'No description needed :)';

//set the day in numeric format
$today = date("w");
//switch statement
switch($today) {
case
"0" :
print(
"$url_0 <br> $url0_desc");
break ;
case
"1":
print(
"$url_1 <br> $url1_desc");
break;
case
"2" :
print(
"$url_2 <br> $url2_desc");
break ;
case
"3" :
print(
"$url_3 <br> $url3_desc");
break;
case
"4" :
print(
"$url_4 <br> $url4_desc");
break;
case
"5" :
print (
"$url_5 <br> $url5_desc");
break;
case
"6" :
print(
"$url_6 <br> $url6_desc");
break;
default:
print(
"<strong> THE SERVER CAN NOT FIGURE WHAT DAY IT IS TRY THIS PAGE </strong> $url_0");
}
?>
</center>
</body>
</html>



Note to myself "I must remember ";" ":" " :)

 

 (#418 2003-12-17 14:53:45) Post Reply
Page 0 1 2 3 4 5

Shannen
Need To Set


Enrolled: Dec 2003
Posts: 3
AP: 1

It seemed like it took forever, but once I got it it was so simple. I used the posts from other people when I was really stuck on syntax, so thanks to everyone who posted.



<?PHP

$today
=date('w');


?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
switch($today)
{
case
'0':
$link="Today is Sunday the link of the day is: <a href='http://www.perftestplus.com/'> www.perftestplus.com</a> All about performance";
break;
case
'1':
$link="Today is Monday the link of the day is: <a href='http://www.yahoo.com/'> www.yahoo.com<a> A nice search engine site";
break;
case
'2':
$link="Today is Tuesday the link of the day is: <a href='http://designsbyshannen.com/collardco/index.htm'> www.collardco.com</a> My Clients site ";
break;
case
'3':
$link="Today is Wednesday the link of the day is: <a href='http://www.johnthree16.info'> www.john3:16.com</a> This is my Papa's site.";
break;
case
'4':
$link="Today is Thursday the link of the day is: <a href='http://www.scriptschool.com'> www.scriptschool.com</a> This is the classes site.";
break;
case
'5':
$link="Today is Friday the link of the day is: <a href='http://www.ebay.com'> www.ebay.com</a> This is a great site for Christmas presents.";
break;
case
'6':
$link="Today is Saturday the link of the day is: <a href='http://college.espn.go.com/ncf/index'> www.collegefootball.com</a> Today's the day for college football...GO HOKIES!!!";
break;
default:
$link="Very interesting...I wonder where you're from??? There's no day of the week.....";
}
print(
$link)
?>


</body>
</html>


 

 (#420 2003-12-19 12:23:17) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

quote:
I used the posts from other people when I was really stuck on syntax, so thanks to everyone who posted.


Well done, Shannen, this is the way it works :) Hopefully you can help others if you see someone like Quicksaver has been doing.

 

 (#421 2003-12-20 10:14:54) Post Reply
Page 0 1 2 3 4 5

Ahkorahil
Need To Set


Enrolled: Oct 2003
Posts: 20
AP: 1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 2. assignment </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<?php
//lingid
$sunlink ="<a href=http://www.zone.ee>zone</a>";
$monlink ="<a href=http://www.neti.ee>neti</a>";
$tuelink ="<a href=http://www.hot.ee>hot</a>";
$wedlink ="<a href=http://www.delfi.ee>delfi</a>";
$thulink ="<a href=http://www.php.ee>pHp</a>";
$frilink ="<a href=http://www.scriptschool.com>school</a>";
$satlink ="<a href=http://www.zone.ee/eastwestclan>eastwest</a>";
//descriptions
$sundes ="zone--- I set my php pages there";
$mondes ="search";
$tuedes ="mail for me";
$weddes ="news!";
$thudes ="estonian php";
$frides ="scriptschool for everyone";
$satdes ="Counterstrike clan";
//today
$today =date("l");
switch($today)
{
case"Sunday":
print("$today<br>$sunlink <br> $sundesc");
break;
case"Monday":
print("$today<br> $monlink <br> $mondes");
break;
case"Tuesday":
print("$today<br> $tuelink <br> $tuedes");
break;
case"Wednesday":
print("$today<br> $wedlink <br> $weddes");
break;
case"Thursday":
print("$today<br> $thulink <br> $thudes");
break;
case"Friday":
print("$today<br> $frilink <br> $frides");
break;
default:
print("$today<br> $satlink <br> $satlink");
?>
</BODY>
</HTML>
////The line is 54th and I got an error:
Parse error: parse error in /www/data03/users/t/test003/new.php3 on line 54
Can You give me any advice

 

 (#422 2003-12-21 08:13:16) Post Reply
Page 0 1 2 3 4 5

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

ahkorahil, you didnt close the switch() :)

put an } at the end to close it

 

 (#423 2003-12-22 01:47:33) Post Reply
Page 0 1 2 3 4 5

logspirit
Need To Set


Enrolled: Oct 2001
Posts: 63
AP: 1

MarcusD79,
I don't usually respond to threads in this course, but I happened to notice that you're having a problem with Your quotes... You must nest Your quotes properly, or use one of the other methods I suggest below... You were breaking out of Your double quote after the
href=


.



//Following are values for days
$_sun0="$_today s Link is to <a href="http://www.fagfrat.com/photos">Photo Page</a>.";



$_sun0='$_today s Link is to <a href="http://www.fagfrat.com/photos">Photo Page</a>.';


$_today


$_sun0="\$_today s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>.";



But actually, I don't really think You want to print out either the numerical for the day (0-6) OR the phrase $_today as a word...! Rather I think You would want to print the name of the day such as Tuesday etc... see other examples in this thread above, to see how to do this...

Please also see:
http://us3.php.net/types.string
and:
http://www.zend.com/zend/tut/u...ing-strings.php
for a fuller discussion of PHP's string syntax.

logspirit - author of the MySQL and Javascript courses

 

 (#424 2003-12-22 01:58:53) Post Reply
Page 0 1 2 3 4 5

logspirit
Need To Set


Enrolled: Oct 2001
Posts: 63
AP: 1

My Last post was really garbled by the code tags... also I didn't realize that this string had gone to two pages and these problems were worked out... at any rate this is what I was attempting to say:

MarcusD79,
I don't usually respond to this course, but I happened to notice that you're having a problem with Your quotes... You must nest Your quotes properly... If You start with double quotes the next inner nest uses single quotes, the next inner nest within that single quoted one would be double quoted etc. You were breaking out of Your double quote after the href=" Nor were You concatenating the rest of the string on either (using a . )

So:

//Following are values for days
$_sun0="$_today s Link is to <a href="http://www.fagfrat.com/photos">Photo Page</a>.";

Could be:

$_sun0='$_today s Link is to <a href="http://www.fagfrat.com/photos">Photo Page</a>.';

Please notice the single quotes in the outer string and then double quotes in the inner nest... using single quotes is faster for PHP and should always be used preferentially UNLESS You are auto parsing variables within the string - which requires double quotes and is slower (to check for, and parse existing variables within the string)! Note that single quoting results in LITERAL interpretations!

Another alternative would be to slash out the inner double quotes AND Your variable's $ sign, so that PHP doesn't try to parse it as a variable! Which it can't do in this instance anyway, since $_today is an ARRAY which has not had it's inner location specified. Slashing out the quotes and variables allows them to be printed out as LITERALS without affecting the functionality of Your script.:

$_sun0="\$_today s Link is to <a href=\"http://www.fagfrat.com/photos\">Photo Page</a>.";

But actually, I don't really think You want to print out either the numerical for the day (0-6) OR the phrase $_today as a word...! Rather I think You would want to print the name of the day such as Tuesday etc... see other examples in this thread above, to see how to do this... Please also see: http://us3.php.net/types.string and http://www.zend.com/zend/tut/u...ing-strings.php for a fuller discussion of PHP's string syntax.

logspirit - author of the MySQL and Javascript courses

 

 (#426 2003-12-25 11:54:49) Post Reply
Page 0 1 2 3 4 5

TylerTT
Need To Set


Enrolled: Dec 2003
Posts: 2
AP: 1



<html>
<head>
<title>URL Display</title>
</head>
<body>
<?php

// Set the day
$day = date("w");

// Set URL, title, and description
switch($day) {
case
"0":
$URL = "yahoo.com";
$title = "Yahoo";
$description = "Yahoo.com news, search, mail, media, and games.";
break;
case
"1":
$URL = "google.com";
$title = "Google";
$description = "Google.com ultimate public internet search engine.";
break;
case
"2":
$URL = "msn.com";
$title ="Microsoft Network MSN";
$description = "Microsoft Network, information, news, search, mail, and much more.";
break;
case
"3":
$URL = "ebay.com";
$title = "E-bay";
$description = "E-bay, online buying and selling.";
break;
case
"4":
$URL = "dell.com";
$title = "Dell";
$description ="Purchase Dell products on and off-line.";
break;
case
"5":
$URL = "php.net";
$title = "PHP.net";
$description = "PHP.net- download or learn PHP.";
break;
case
"6":
$URL = "scriptschool.com";
$title = "Script School";
$description = "Learn different scripts online.";
break; }

// Print out the info
echo "<table cellpadding="0" cellspacing="1" bgcolor="#000000"><tr>";
echo "<td width="300" bgcolor="#CCCCCC">";
echo "<b>$title -</b><a href="http://www.$URL">http://www.$URL</a>";
echo "</td></tr>";
echo
"<td width="300" bgcolor="#FFFFFF">";
echo "<div style="text-indent:10">$description</div>";
echo
"</td></tr></table>";
?>



 

 (#429 2003-12-26 00:58:10) Post Reply
Page 0 1 2 3 4 5

n2o2k
Need To Set


Enrolled: Dec 2003
Posts: 6
AP: 1



<?
/****************************************
* To do Assignement #2 *
* by n2o_2k *
* n2o_2k@hotmail.com *
* *
****************************************************/

?>
<html>
<HEAD>
<TITLE>SchoolScript.com Assignment 2 - URL of the Day</TITLE>
</HEAD>
<BODY>
<?
//intialise variables
$url="";
$urldescription="";

//check the current day of the week
//and select the appropriate url and description
switch(date("w"))
{
case
0;//sunday
break;
case
1;//monday
$url = "www.automotiveforums.com";
$urldescription="The largest automotive forums.";
break;
case
2;//tuesday
$url = "www.hotmail.com";
$urldescription="Free email acount by Micro$oft";
break;
case
3;//wednesday
$url = "www.altavista.com";
$urldescription="A search engine";
break;
case
4;//thursday
$url = "www.google.com";
$urldescription="Another search engine";
break;
case
5;//friday
$url = "www.justlinux.com";
$urldescription="Good place to start learning some linux";
break;
case
6;//saturday
$url = "www.linux.org";
$urldescription="Linux How to documents";
break;
}
//end of the switch

//print the url and description
print("Url of the day: <a href=\"http://".$url."\">".$urldescription."</a>");
print(
"<br>".date("m/d/y"));

?>
</html>


 

 (#433 2003-12-27 23:06:17) Post Reply
Page 0 1 2 3 4 5

PureGrain
Need To Set


Enrolled: Nov 2003
Posts: 14
AP: 1



<html>
<head>
<title>Lesson 2 Switch</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center">This is actually lesson 2.
<br>I just added the other part of lesson 2 because it was a challenge as well as this one.
<br>TO-DO ASSIGNMENT: Write a script to print to the browser a different url
<br>each day of the week using the switch and case statement.
<br>My script begins here:<hr></p>
<p align="center">
<?php
// This program will use the switch/case function to display a different url each day.
// Get the numerical day of the week and assign it to a variable.

$today= date("w");
//Links and discription of the links.
switch($today)
{
case
0:
$link = ("My favorite game <a href='http://www.tribes2.com'>Tribes 2</a>");
break;
case
1:
$link = ("My website <a href='http://www.completronics.com'>Completronics</a>");
break;
case
2:
$link = ("My starting point <a href='http://www.google.com'>Google</a>");
break;
case
3:
$link = ("A great place to download things <a href='http://www.downloads.com'>Downloads.com</a>");
break;
case
4:
$link = ("My friends band website <a href='http://www.factor9.net'>Factor 9</a>");
break;
case
5:
$link = ("The go to web site <a href='http://www.techtv.com'>Tech TV</a>");
break;
case
6:
$link = ("My favorite spot to download drivers <a href='http://www.driverguide.com'>DriverGuide.com</a>");
break;
default:
print (
"error");
}
//Now to print it to the browser
print ("Here is todays link:<br> $link" . "<br>" . "<br>");
// I added these two lines below with some of the concepts I gathered from forums while searching for the line break problem I was having.
$copy ='<a href="mailto:cholt215@msn.com">©WebMag2000-2004</a>';
$link ='<a href="http://www.completronics.com">Completronics.com</a>';
echo
nl2br("$copy" . "<br>"."$link")

?></p>

</body>
</html>



The reason for extra writing in the heading is due to me posting my success on a web site that I am putting together for my referance. Hope this is right! Crosses Fingers!!

 

 (#435 2003-12-28 11:35:50) Post Reply
Page 0 1 2 3 4 5

PureGrain
Need To Set


Enrolled: Nov 2003
Posts: 14
AP: 1

I was just tinkering with the other parts of the lessons, like the diff pic for every day of the week. Which i was ablr to get to work. Then after completing the assignment, I decided to go back and do the Escape from PHP to output HTML. I cannot seem to get this to work. Can you look at the code and tell me where I went wrong?

<html>
<head>
<title>Lesson 2 Escaping PHP to HTML</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p align="center">Another part of lesson 2<br>Escaping PHP to HTML<br>Script begins here:<hr>
<?
//Lesson 2 also shows how to escape PHP to output html
$today = date("l");
if(
$today = "Saturday"){//begin loop, everything below will ONLY show if the day of the week is Saturday
?>
<p align="center">Escaping to output HTML<br>One thing about php that is nice that inside a loop you can
escape to HTML.
<br>This is very useful if you don't have to interpret any code.<br>If you see this, then today is Saturday
</p>
<?
} //end loop
?>
<p align="center">
<?
// I added these two lines below with some of the concepts I gathered from forums while searching for the line break problem I was having.
$copy ='<a href="mailto:cholt215@msn.com">&copy;WebMag2000-2004</a>';
$link ='<a href="http://www.completronics.com">Completronics.com</a>';
echo
nl2br("$copy" . "<br>" . "$link")
?></p>
</body>
</html>



Thanks in advance.

 

  Page 0 1 2 3 4 5

View Previous Thread
Print this page Print This Page

View Next Thread

School Map:  Home / Enroll $ Student Records; Class  
$ News @ LIVE Tech Radio * Support/FAQ | Store

Advertising | Link To Us | Privacy 
Copyright 2000-2002 Script School Productions / KMR Enterprises 
No part of this website may be reproduced, copied and/or distributed in any medium 
without express written permission