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

Class / Forums / php101 Refresh the current page Post your Week 2 Basic To-Do Assignment here
 

 (#2 2003-08-07 15:35:03) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

Your Week #2 Basic TO-DO assignment should be posted here in this thread only. If you have specific questions about the week 2 course text then please also post them in this thread so that other students can learn from the information. General questions about Script School should be posted in the homeroom forum.

TO-DO ASSIGNMENT: Write a script to print to the browser a different url each day of the week using the switch and case statement.

 

 (#33 2003-08-08 11:02:46) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

I did the week 2 basic assignment, but I keep getting a parse error pn line 11. Help!!!



<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.
$sunlink = "<A HREF = http://www.dandrenterprises.co...gt;</A>";
$sunlinkdesc = "D and R Enterprises";
$monlink = "<A HREF = http://www.eoepa.org></A>";
$monlinkdesc = "Eastern Ozarks Environmental Preservation Association";
$tueslink = "<A HREF = http://www.scriptschool.com></A>";
$tueslinkdesc = "Script School";
$wedlink = "<A HREF = http://www.hotsheet.com></A>";
$wedlinkdesc = "Hot Sheet";
$thurlink = "<A HREF = http://www.ytmag.com/cgi-bin/a...gt;</A>";
$thurlinkdesc = "Yesterday's Tractors Auction";
$frilink = "<A HREF = http://www.ebay.com></A>";
$frilinkdesc = "ebay";
$satlink = "<A HREF = http://www.neargeekhosting.com...gt;</A>";
$satlinkdesc = "neargeek web hosting";
// SWITCH
switch ($today) {
case 0:
print ("Today's link is: " . $sunlinkdesc<br> . $sunlink);
break;
case 1:
print ("Today's link is: " . $monlinkdesc<br> . $monlink);
break;
case 2:
print ("Today's link is: " . $tueslinkdesc<br> . $tueslink);
break;
case 3:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);
break;
case 4:
print ("Today's link is: " . $thurlinkdesc<br> . $thurlink);
break;
case 5:
print ("Today's link is: " . $frilinkdesc<br> . $frilink);
break;
default:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);

?>
</BODY>
</HTML>


 

 (#35 2003-08-08 13:17:03) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

You are missing the terminator on this line:

$today = date("w")

It should read:

[php]
$today = date("w");
[/php]

When you post your assignments, make sure to use the code tag so the board will format it properly. It will also display the code in color format and that can make it easier to spot errors like the one above.

Keep up the good work :)

 

 (#36 2003-08-08 13:18:35) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

er, in my example above, be sure to use the word code instead of php for the color coding.



<?php
/*
an example of color coding
using code [ code ] and [ /code ] (no spaces
*/
?>



 

 (#37 2003-08-08 14:04:16) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

I fixed the one problem, but now there is another parse error in line 28. I also do not understand what you mean about using the code tag to make the pasted code appear right. Sorry to be a pain.


<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.
$sunlink = "<A HREF = http://www.dandrenterprises.co...gt;</A>";
$sunlinkdesc = "D and R Enterprises";
$monlink = "<A HREF = http://www.eoepa.org></A>";
$monlinkdesc = "Eastern Ozarks Environmental Preservation Association";
$tueslink = "<A HREF = http://www.scriptschool.com></A>";
$tueslinkdesc = "Script School";
$wedlink = "<A HREF = http://www.hotsheet.com></A>";
$wedlinkdesc = "Hot Sheet";
$thurlink = "<A HREF = http://www.ytmag.com/cgi-bin/a...gt;</A>";
$thurlinkdesc = "Yesterday's Tractors Auction";
$frilink = "<A HREF = http://www.ebay.com></A>";
$frilinkdesc = "ebay";
$satlink = "<A HREF = http://www.neargeekhosting.com...gt;</A>";
$satlinkdesc = "neargeek web hosting";
// SWITCH
switch ($today) {
case 0:
print ("Today's link is: " . $sunlinkdesc<br> . $sunlink);
break;
case 1:
print ("Today's link is: " . $monlinkdesc<br> . $monlink);
break;
case 2:
print ("Today's link is: " . $tueslinkdesc<br> . $tueslink);
break;
case 3:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);
break;
case 4:
print ("Today's link is: " . $thurlinkdesc<br> . $thurlink);
break;
case 5:
print ("Today's link is: " . $frilinkdesc<br> . $frilink);
break;
default:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);

?>
</BODY>
</HTML>


 

 (#38 2003-08-08 14:06:26) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

[code]
<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.
$sunlink = "<A HREF = http://www.dandrenterprises.co...gt;</A>";
$sunlinkdesc = "D and R Enterprises";
$monlink = "<A HREF = http://www.eoepa.org></A>";
$monlinkdesc = "Eastern Ozarks Environmental Preservation Association";
$tueslink = "<A HREF = http://www.scriptschool.com></A>";
$tueslinkdesc = "Script School";
$wedlink = "<A HREF = http://www.hotsheet.com></A>";
$wedlinkdesc = "Hot Sheet";
$thurlink = "<A HREF = http://www.ytmag.com/cgi-bin/a...gt;</A>";
$thurlinkdesc = "Yesterday's Tractors Auction";
$frilink = "<A HREF = http://www.ebay.com></A>";
$frilinkdesc = "ebay";
$satlink = "<A HREF = http://www.neargeekhosting.com...gt;</A>";
$satlinkdesc = "neargeek web hosting";
// SWITCH
switch ($today) {
case 0:
print ("Today's link is: " . $sunlinkdesc<br> . $sunlink);
break;
case 1:
print ("Today's link is: " . $monlinkdesc<br> . $monlink);
break;
case 2:
print ("Today's link is: " . $tueslinkdesc<br> . $tueslink);
break;
case 3:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);
break;
case 4:
print ("Today's link is: " . $thurlinkdesc<br> . $thurlink);
break;
case 5:
print ("Today's link is: " . $frilinkdesc<br> . $frilink);
break;
default:
print ("Today's link is: " . $wedlinkdesc<br> . $wedlink);

?>
</BODY>
</HTML>
[/code]

OK I got it now.

 

 (#39 2003-08-12 06:47:41) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

I have still been working diligently on the week 2 basic assignment. I still can't get it to work. I have made some changes to take small steps toward the actual assignment, but I just can't get there. Can you help with this code below, then I will work from there to complete the assignment as it should be. Thanks.

[php]
<HTML>
<HEAD>
<TITLE>ScriptSchool.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.
$sunlink = "<A HREF = http://www.dandrenterprises.co...gt;</A>";
$sunlinkdesc = "D and R Enterprises";
$monlink = "<A HREF = http://www.eoepa.org></A>";
$monlinkdesc = "Eastern Ozarks Environmental Preservation Association";
$tueslink = "<A HREF = http://www.scriptschool.com></A>";
$tueslinkdesc = "Script School";
$wedlink = "<A HREF = http://www.hotsheet.com></A>";
$wedlinkdesc = "Hot Sheet";
$thurlink = "<A HREF = http://www.ytmag.com/cgi-bin/a...gt;</A>";
$thurlinkdesc = "Yesterday's Tractors Auction";
$frilink = "<A HREF = http://www.ebay.com></A>";
$frilinkdesc = "ebay";
$satlink = "<A HREF = http://www.neargeekhosting.com...gt;</A>";
$satlinkdesc = "neargeek web hosting";
// SWITCH
switch ($today) {
case 0:
print($sunlink);
print ($sunlinkdesc);
break;
case 1:
print($monlink);
print($monlinkdesc);
break;
case 2:
print($tueslink);
print($tueslinkdesc);
break;
case 3:
print($wedlink);
print($wedlinkdesc);
break;
case 4:
print($thurlink);
print($thurlinkdesc);
break;
case 5:
print($frilink);
print($frilinkdesc);
break;
default:
print($satlink);
print($satlinkdesc);
?>
</BODY>
</HTML>
[/php]

 

 (#40 2003-08-12 13:04:36) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

Hi Donnie

You should be able to add:

[ code ]
code goes here
[ /code ]

Just remove the spaces between the brackets and make sure that the colorize checkbox is checked.

This way I can review your actual source code instead of the version that is being converted by the board

 

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

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

BTW, what you did in message #38 looks right, but I think maybe you didn't check the colorize code box?

 

 (#42 2003-08-12 14:13:01) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1



<HTML>
<HEAD>
<TITLE>ScriptSchool.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.
$sunlink="<A HREF = <A HREF="http://www.dandrenterprises.com></A>";" TARGET=_blank>http://www.dandrenterprises.co...gt;</A>";</A>
$sunlinkdesc="D and R Enterprises";
$monlink="<A HREF = <A HREF="http://www.eoepa.org></A>";" TARGET=_blank>http://www.eoepa.org></A>";</A>
$monlinkdesc="Eastern Ozarks Environmental Preservation Association";
$tueslink="<A HREF = <A HREF="http://www.scriptschool.com></A>";" TARGET=_blank>http://www.scriptschool.com></A>";</A>
$tueslinkdesc="Script School";
$wedlink="<A HREF = <A HREF="http://www.hotsheet.com></A>";" TARGET=_blank>http://www.hotsheet.com></A>";</A>
$wedlinkdesc="Hot Sheet";
$thurlink="<A HREF = <A HREF="http://www.ytmag.com/cgi-bin/auction.cgi></A>";" TARGET=_blank>http://www.ytmag.com/cgi-bin/a...gt;</A>";</A>
$thurlinkdesc="Yesterday's Tractors Auction";
$frilink="<A HREF = <A HREF="http://www.ebay.com></A>";" TARGET=_blank>http://www.ebay.com></A>";</A>
$frilinkdesc="ebay";
$satlink="<A HREF = <A HREF="http://www.neargeekhosting.com></A>";" TARGET=_blank>http://www.neargeekhosting.com...gt;</A>";</A>
$satlinkdesc="neargeek web hosting";
// SWITCH
switch($today){
case
0:
print(
$sunlink);
print(
$sunlinkdesc);
break;
case
1:
print(
$monlink);
print(
$monlinkdesc);
break;
case
2:
print(
$tueslink);
print(
$tueslinkdesc);
break;
case
3:
print(
$wedlink);
print(
$wedlinkdesc);
break;
case
4:
print(
$thurlink);
print(
$thurlinkdesc);
break;
case
5:
print(
$frilink);
print(
$frilinkdesc);
break;
default:
print(
$satlink);
print(
$satlinkdesc);
?>
</BODY>
</HTML>



Colorize is checked. No spaces inside brackets.
When I previewed post #38, it was colorized, when I posted it, it wasn't.

I am not going to previewit this time, just submit it.

Hopefully then you will be able to look at what I have done and give me a hint as to why the program will not work. I am getting a parse error on the last line. Thanks.

 

 (#43 2003-08-15 11:28:58) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

Hi Donnie,

You are missing the closing bracket for your switch case statement. That's why you are getting an error. Needs to be like this:



<?php
switch($info){
case
0:
//item 1
break;
default:
//default item
}
?>



 

 (#44 2003-08-15 14:22:09) Post Reply
Page 0 1 2 3 4 5

Donnie
Need To Set


Enrolled: Aug 2003
Posts: 41
AP: 1

Thanks TDavid. I just couldn't see that I had left that bracket off. It was about to drive me nuts. Below is the completed code. I think it partially fulfills the requirements for the advanced assignment. I'm off to try it.



<HTML>
<HEAD>
<TITLE>ScriptSchool.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.
$sunlink="<A HREF = <A HREF="http://www.dandrenterprises.com>www.dandrenterprises.com</A>";" TARGET=_blank>http://www.dandrenterprises.co...com</A>";</A>
$sunlinkdesc="<br><b>D and R Enterprises</b>My site.It needs some work.";
$monlink="<A HREF = <A HREF="http://www.eoepa.org>www.eoepa.org</A>";" TARGET=_blank>http://www.eoepa.org>www.eo...org</A>";</A>
$monlinkdesc="<br><b>E</b>astern <b>O</b>zarks <b>E</b>nvironmental <b>P</b>reservation <b>A</b>ssociation";
$tueslink="<A HREF = <A HREF="http://www.scriptschool.com>www.scriptschool.com</A>";" TARGET=_blank>http://www.scriptschool.com&gt...com</A>";</A>
$tueslinkdesc="<br><i>Script School</i>, I'm glad I found you!";
$wedlink="<A HREF = <A HREF="http://www.hotsheet.com>www.hotsheet.com</A>";" TARGET=_blank>http://www.hotsheet.com>www...com</A>";</A>
$wedlinkdesc="<br>This is a great page of links!";
$thurlink="<A HREF = <A HREF="http://www.ytmag.com/cgi-bin/auction.cgi>Yesterday's" TARGET=_blank>http://www.ytmag.com/cgi-bin/a...gt;Yesterday's</A> Tractors Auction</A>";
$thurlinkdesc="<br>This is a small auction site mostly for farm related collectibles, but. . . .<br>You never know what you will find here.";
$frilink="<A HREF = <A HREF="http://www.ebay.com>ebay</A>";" TARGET=_blank>http://www.ebay.com>ebay</A>";</A>
$frilinkdesc="<br>A <b><u><i>great</i></b></u> internet auction site!";
$satlink="<A HREF = <A HREF="http://www.neargeekhosting.com>www.neargeekhosting.com</A>";" TARGET=_blank>http://www.neargeekhosting.com...com</A>";</A>
$satlinkdesc="A friend of mine who provides server space.<b>Check this out!</b>";
// SWITCH
switch($today){
case
0:
print(
$sunlink);
print(
$sunlinkdesc);
break;
case
1:
print(
$monlink);
print(
$monlinkdesc);
break;
case
2:
print(
$tueslink);
print(
$tueslinkdesc);
break;
case
3:
print(
$wedlink);
print(
$wedlinkdesc);
break;
case
4:
print(
$thurlink);
print(
$thurlinkdesc);
break;
case
5:
print(
$frilink);
print(
$frilinkdesc);
break;
default:
print(
$satlink);
print(
$satlinkdesc);
}
?>
</BODY>
</HTML>



 

 (#46 2003-08-16 02:49:02) Post Reply
Page 0 1 2 3 4 5

ipcn
Need To Set


Enrolled: Aug 2003
Posts: 2
AP: 1

Okay, i keep getting errors on Line 7 & 9 when using this script. Any ideas?
[php]
<html>
<head>
<title>URL of the day</title>
</head>
<body>
<?
//Get the day and store it
$day = date("w");
//Now, get the URL for each day and store it
switch($day)
{
case "0": $url = "http://www.ipcn.co.uk";
break;
case "1": $url = "http://www.ps2zone.tk";
break;
case "2": $url = "http://www.scriptschool.com";
break;
case "3": $url = "http://www.google.com";
break;
case "4": $url = "http://www.nichnet.co.uk";
break;
case "5": $url = "http://www.dot.tk";
break;
case "6": $url = "http://www.food.com";
break;
default: $url = "#";
}
//Now get a Title for each URL
switch($day)
{
case "0": $title = "IPC Network";
break;
case "1": $title = "PS2 Zone";
break;
case "2": $title = "ScriptSchool";
break;
case "3": $title = "Google";
break;
case "4": $title = "NichNet";
break;
case "5": $title = "DotTK";
break;
case "6": $title = "Food.com";
break;
default: $title = "ERROR: Please Refresh";
}
//Now, a description

switch($day)
{
case "0": $desc = "The International People's Chat Network";
break;
case "1": $desc = "PS2 Zone, Your #1 Source for PS2 Chat, Games, and other things!";
break;
case "2": $desc = "The best place to find tutorial to learn a new Scripting Language";
break;
case "3": $desc = "Google -- World's #1 Search Engine";
break;
case "4": $desc = "Great Free Hosting";
break;
case "5": $desc = "Get a free .tk domian name";
break;
case "6": $desc = "Food.com, your definitive guide";
break;
default: $desc = "ERROR: Please Refresh";
}
//Now, lets print it out
print("<a href="$url">$title</a><br><br>$desc");
//End script
?>
[/php]

 

 (#51 2003-08-16 15:29:40) Post Reply
Page 0 1 2 3 4 5

Sk8rRIMuk
Need To Set


Enrolled: Aug 2003
Posts: 39
AP: 1

Heres my script:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Sk8rRIMuk's Url-A-Day Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<center>
<?php
//The date is assigned to a variable
$today=date("j/n/y");
//Print the date in context
print("<p>Thecurrentdateis: <b>$today</b></p>");
//Set the numerical day to a variable
$day=date("w");
//Set the switches to print the URL's based on that variable
switch("$day")
{
//Sundays site
case"0":
print(
"<p>Todays URL:<br /><b><a href="http://www.katikai.com" target="_blank">Katikai Web Hosting</a></b></p>
<p>Description:<br/>KatikaiWebHostingisawebsiterunbymyfriendChrisFinch,heoffersfreewebhostingwith
php
,mysql,ftpandnumerousotherfeaturestoanybodywhohasagoodsitewithanicedesignthathethinkswould
belongthere
.</p>");
break;
//Mondays site
case "
1" :
print ("
<p>TodaysURL:<br/><b><ahref="http://www.n00bstories.com"target="_blank">n00bstories</a></b></p>
<
p>Description:<br/>n00bstoriesisasiterunbythePHPaceCrimson,thesiteisaplaceforthemanyplayers
ofRenegadetoreportn00bs
andreadeachothersstories,italsoishometothecommunityforums,crimsons
server
andthesniperforums.</p>");
break;
//Tuesdays site
case "
2" :
print ("
<p>TodaysURL:<br/><b><ahref="http://renegade.the-pitts.net"target="_blank">ThePitts</a></b></p>
<
p>Description:<br/>ThePittsishometotheofficialforumsofThePittsRenegadeserverhereyoucandiscuss
manythingsrelatingtotheserver
andonlinegaming.</p>");
break;
//Wednesdays site
case "
3" :
print ("
<p>TodaysURL:<br/><b><ahref="http://www.teamspeak.org"target="_blank">Teamspeak</a></b></p>
<
p>Description:<br/>TeamspeakisthewebsiteforthevoicechatclientTeamspeak,hereyoucandownloadthe
program
,getserverlinksorparticipateinforumdiscussions.</p>");
break;
//Thursdays site
case "
4" :
print ("
<p>TodaysURL:<br/><b><ahref="http://www.arm-ent.com"target="_blank">Arm-Ent</a></b></p>
<
p>Description:<br/>Arm-EntisaahostingstefornumerousCommandadnConquerbasedsitescontaining
thelikesoftheRenegadeAlertModifcaton
,AlliesRevengeModifictaionandmuchmore.</p>");
break;
//Fridays site
case "
4" :
print ("
<p>TodaysURL:<br/><b><ahref="http://download.com.com"target="_blank">Download.com</a></b></p>
<
p>Description:<br/>Icannotdescribedownload.cominanyotherwayexcept:theultimatesiteforshareware,
freewareandanyothertypeofsoftwareyoucouldeverdreamof.Ihighelyrecommendthissitefordownloads.</p>");
break;
//Saturdays site
case "
6" :
print ("
<p>TodaysURL:<br/><b><ahref="http://www.laeubi.de"target="_blank">laeubi.de-ModdingPage</a></b></p>
<
p>Description:<br/>ThiswebsiteisrunbymyGermanfriendLaeubi,thesiteisdedicatedtoRenegademods,modding
tutorials
,scriptsandtohelpyououtwithyourproblems.ThissitewaswrittenbyhandbyLaeubi,anotherPHP
ace
.</p>");
break;
//Ifitisneitherday
default:
print('<p>Sorrythereisanerrorwiththeserversdateasitisnotreportinganyday.</p>');
break;
}
?>
<p>CopyrightSk8rRIMuk©2003</p>
</body>
</html>



take out the spaces in the code or is that just for the preview?

Anywyas I haev a working example at:
<A HREF="http://www.katikai.com/ee/test/date.php" TARGET=_blank>http://www.katikai.com/ee/test/date.php</A>


 

 (#76 2003-08-20 12:31:07) Post Reply
Page 0 1 2 3 4 5

MasterD
Need To Set


Enrolled: Aug 2003
Posts: 10
AP: 1



<?php
//date ?
$today=date("w");
$day=date("l");

//Link + Discription
$link1="$day'slinkis: <br/> <ahref='http://www.-devil.tk'> -Devil.tk</a> <br/>Myownsite:)";
$link2="$day'slinkis: <br/> <ahref='http://www.e107.org'>e107.org</a>Thehomesiteoftheportalthatpowersmysite";
$link3="$day'slinkis: <br/> <ahref='http://www.e107coders.org'>e107coders.org</a>Pluginsfore107:DIwannahelpthem...growbrainGROW!";
$link4="$day'slinkis: <br/> <ahref='http://www.e107themes.org'>e107themes.org</a>Themesfore107,Don'tforgettocheckoutmythemes;)";
$link5="$day'slinkis: <br/> <ahref='http://www.mozilla.org'>Mozilla.org</a>Getfirebird!It'swaaaaaaaaybetterthenIE";
$link6="$day'slinkis: <br/> <ahref='http://www.emotioneric.com'>Emotioneric.com</a>Igarantueeyouthatthisguywillmakeyou'lllaughsomuchthatyou'llstartcrying";
$link0="$day'slinkis: <br/> <ahref='http://213.93.47.213'>TestServer</a>Mytestserverwhereyoucanseedanewestshit;)";

//date !
switch($today){

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

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

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

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

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

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

case
"0":
print(
"$link0");
break;
}
?>




I'm not sure if I was supposed to do it like this, but I think the assignment was this ?

 

 (#78 2003-08-20 13:23:30) Post Reply
Page 0 1 2 3 4 5

MasterD
Need To Set


Enrolled: Aug 2003
Posts: 10
AP: 1

Sorry for the tripple post .... I guess I should stop using the back button on this site
My apoligies, It was not my intention to spam

 

 (#84 2003-08-23 10:22:03) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

Re #46, ipcn:

quote:

print("<a href="$url">$title</a><br><br>$desc");


You have backslashes in front of the double quotes right?

 

 (#94 2003-08-26 14:44:52) Post Reply
Page 0 1 2 3 4 5

jthwalker
Need To Set


Enrolled: Aug 2003
Posts: 2
AP: 1

<HTML>
<HEAD>
<TITLE>Assignment Week 2 - Different URL Each Day </TITLE>
</HEAD>
<BODY>
<?
// Program to display a different URL for each day of the week
//listing day of the week from 0-6
$day = date("w");

//links and link info
$day0="$day's Site of the Day is: <p> <a href='http://www.sosaenterprises.com'> http://www.SOSAEnterprises.com </a> My OWN web design business!";
$day1="$day's Site of the Day is: <p> <a href='http://www.pmin.net'> http://www.pmin.net</a> My site - The William P. Brewer Memorial Purple Martin Information Network";
$day2="$day's Site of the Day is: <p> <a href='http://www.lifehouse.150m.com'> http://www.lifehouse.150m.com</a> My web-based church!";
$day3="$day's Site of the Day is: <p> <a href='http://www.vilitas.com'> http://www.vilitas.com </a> My web host!";
$day4="$day's Site of the Day is: <p> <a href='http://www.scriptschool.com'> http://www.scriptschool.com</a> Scripting Instruction At it's Best!";
$day5="$day's Site of the Day is: <p> <a href='http://www.abcnews.com'> http://www.abcnews.com </a> ABC News!";
$day6="$day's Site of the Day is: <p> <a href='http://www.yahoo.com'> http://www.yahoo.com </a> Yahoo! Search Engine!";

//Now the switch/case part
switch("$day")
{
case "0":
print("$day0");
break;

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

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

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

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

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

case "6":
print("$day6");
break;
}
?>
</BODY>
</HTML>


Is my script ok? I didn't really understand about the layout of the links on switch case, but tried to follow along as I studied the other students work.

 

 (#136 2003-08-29 21:51:42) Post Reply
Page 0 1 2 3 4 5

TDavid
php mySQL Perl C/C++
Principal


Enrolled: Mar 2000
Posts: 193
AP: 1

jthwalker - what didn't you understand about the switch / case? I'd recommend including a default case.



<?php
switch ($var) {
case
1:
// do this
break;
default:
// else do this
}
?>



 

 (#139 2003-08-31 20:11:19) Post Reply
Page 0 1 2 3 4 5

TecBrat
Need To Set


Enrolled: Aug 2003
Posts: 6
AP: 1

I think I managed to get all the points of the assinment, using only one print function, and concatenating the string.



<?
/*week2*/
$today=date(w);
switch(
$today)
{
case
0: /* sunday */
$site = "My starting place: <a href='http://www.yahoo.com/'>Yahoo </a>";
break;

case
1: /* monday */
$site = "My friend's site: <a href='http://www.deadlydimensions.com/'>Deadly's</a>";
break;

case
2: /* tuesday */
$site = "My little site: <a href='http://web.tampabay.rr.com/tecbrat/'>Tecbrat</a>";
break;

case
3: /* wednesday */
$site = "Search: <a href='http://www.google.com/'>Google</a>";
break;

case
4: /* thursday */
$site = "Multi engine search: <a href='http://www.dogpile.com/'>Dogpile</a>";
break;

case
5: /* friday */
$site = "Free email: <a href='http://www.hotmail.com/'>Hotmail</a>";
break;

case
6: /* saturday */
$site = "My provider: <a href='http://www.rr.com/'>Roadrunner</a>";
break;
default:
print (
"error");
}
print (
"Here's today's link:<br> $site");
?>



 

 (#140 2003-08-31 20:29:18) Post Reply
Page 0 1 2 3 4 5

TecBrat
Need To Set


Enrolled: Aug 2003
Posts: 6
AP: 1

well, I did use a second print statement, but that was just to report a possible error.

 

 (#162 2003-09-06 14:41:00) Post Reply
Page 0 1 2 3 4 5

operations
Need To Set


Enrolled: Sep 2003
Posts: 8
AP: 1



<TITLE>Script School Assignment 2</TITLE>
<center>

<?php
/*TO-DO ASSIGNMENT: Write a script to print to the browser a different url each day of the week
using the switch and case statement..

The Variables*
*/

$today =date("w");
$comment = "Todays Link is : ";


//The Switch

switch($today)
{
case
"0";
$url = "<a href=\"http://adslguide.org.uk\">ADSLGuide</a><br>Broadband news for the UK";
break;
case
"1";
$url = "<a href=\"http://mozilla.org/\">Mozilla.org</a><br>The Mozilla Project";
break;
case
"2";
$url = "<a href=\"http://www.php.net/\">PHP</a><br>The PHP Home Page";
break;
case
"3";
$url = "<a href=\"http://mozilla.org/products/firebird/\">Mozilla Firebird</a><br> Mozilla Firebird is a browser based on Mozilla";
break;
case
"4";
$url = "<a href=\"http://www.fairadsl.co.uk\">Fairbroadband</a><br>Fairbroadband UK's best value broadband provider";
break;
case
"5";
$url = "<a href=\"http://mozilla.org/projects/thunderbird/\">Mozilla Thunderbird</a><br>Mozilla Thunderbird is a redesign of the Mozilla mail component.";
break;
case
"6";
$url = "<a href=\"http://www.google.com\">Google</a><br>The Google search engine";
break;
}
Print
"$comment $url";

?>



 

 (#164 2003-09-07 17:00:17) Post Reply
Page 0 1 2 3 4 5

Nazz
Need To Set


Enrolled: Aug 2003
Posts: 8
AP: 1

Ok Finally, It seemed real confusing at first but after looking at the others and working with it for a while I have it. Only using 1 print function had me going for a while! I do have a couple questions, What if I wanted to change the site of the day to site of the week? switch($week)? Also I dont really understand the default for sure. can I get a little explanation what it actually does? I included it as print error but doesn't php give you a line error anyway? Thankz Nazz

<html>
<head>
<title>Nazz's Second Assignment</title>
</head>
<body>
<center>Nazz's Second Assignment.<br>

<center>
<?
$today="date(w)";
switch($today)
{
case 0:
$site = "Sunday Site of the Day<br>Free Web Hosting: <a href='http://www.t35.com'>T35 </a>";
break;

case 1:
$site = "Monday Site of the Day<br>Game Maker: <a href='http://www.gamemaker.nl/'>Game Maker</a>";
break;

case 2:
$site = "Tuesday Site if the Day<br>Google: <a href='http://www.google.com/'>Google</a>";
break;

case 3:
$site = "Wednesday Site of the Day<br>Free Hosting: <a href='http://www.tripod.lycos.co.uk/taketour/freehosting/'>Tripod</a>";
break;

case 4:
$site = "Thursday Site of the Day<br>3D software: <a href='http://www.legus3d.com/'>3D Software</a>";
break;

case 5:
$site = "Friday Site of the Day<br>Cheap Domain Names: <a href='http://www.voxdomains.com/'></a>";
break;

case 6:
$site = "Saturday Site of the Day<br>Adrift: <a href='http://www.adrift.org.uk/'>Adventure Game Developement</a>";
break;
default:
print ("error");
}
print ("A Different WebSite Every Day:<br> $site");
?>
</body>
<html/>


 

 (#167 2003-09-09 08:02:27) Post Reply
Page 0 1 2 3 4 5

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

hi again, just a lil note for those who know what i mean... why werent arrays introduced in this course? it would be so much easier ;D



<?
$today
= date("w");
$tday = date("l");

switch(
$today) {
case
"0":
$turl = "<a href=\"http://www.sunday.com\">Sunday</a>";
$tdesc = "Sunday's description";
break;
case
"1":
$turl = "<a href=\"http://www.monday.com\">Monday</a>";
$tdesc = "Monday's description";
break;
case
"2":
$turl = "<a href=\"http://www.tuesday.com\">Tuesday</a>";
$tdesc = "Tuesday's description";
break;
case
"3":
$turl = "<a href=\"http://www.wednesday.com\">Wednesday</a>";
$tdesc = "Wednesday's description";
break;
case
"4":
$turl = "<a href=\"http://www.thursday.com\">Thursday</a>";
$tdesc = "Thurday's description";
break;
case
"5":
$turl = "<a href=\"http://www.friday.com\">Friday</a>";
$tdesc = "Friday's description";
break;
case
"6":
$turl = "<a href=\"http://www.saturday.com\">Saturday</a>";
$tdesc = "Saturday's description";
break;
default:
$turl = "no url";
$tdec = "no description"; }

print(
"Today is $tday and for you we have $turl - $tdesc.");
?>




working url

 

 (#168 2003-09-09 08:31:26) Post Reply
Page 0 1 2 3 4 5

Quicksaver
Need To Set


Enrolled: Sep 2003
Posts: 90
AP: 1

by the way, i noticed a discordance from the assignement instructions here and in the tutorial itself, for example one says that only one print fuction can be used and the other doesnt specify. i followed the one on the tutorial because the one "up there" needs a bit more code (a print line for each "case" and the one i used only needs one print line)

just thought you might wanna check it out :)

 

 (#205 2003-09-15 07:40:56) Post Reply
Page 0 1 2 3 4 5

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

Hi, Here is my assignment

<Title>Assignment 02 Script School - URL of the Day</title>
<?
// Just a simple assignment

$sunurl="http://www.cnn.com";
$monurl="http://www.yahoo.com";
$tueurl="http://hk.tom.com";
$wedurl="http://www.hongkong.com";
$thuurl="http://www.pumb.org";
$friurl="http://www.mingpao.com";
$saturl="http://jeffkwan.blogspot.com";


$today=date("j/n/y");
$weekday=date("w");
print("The current date is: ");
print(date("j/n/Y")."<br>");
//choose the day of url

switch($weekday)
{
case 0:
$printlink=$sunurl;
break;
case 1:
$printlink=$monurl;
break;
case 2:
$printlink=$tueurl;
break;
case 3:
$printlink=$wedurl;
break;
case 4:
$printlink=$thuurl;
break;
case 5:
$printlink=$friurl;
break;
case 6:
$printlink=saturl;
break;
}
?>

<p><strong><small><font face="Arial">Output to HTML</font></small></strong></p>

<p><small><font face="Arial">Try to mix it html with php.<br>

Today Link is
<?
print($printlink);
?>
</font></small></p>

 

 (#221 2003-09-16 20:19:21) Post Reply
Page 0 1 2 3 4 5

MarcusD79
Need To Set


Enrolled: Sep 2003
Posts: 10
AP: 1



<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

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

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

case1:
print(
$_mon1);
break;

case2:
print(
$_tue2);
break;

case3:
print(
$_wed3);
break;

case4:
print(
$_thu4);
break;

case5:
print(
$_fri5);
break;

case6:
print(
$_sat6);
break;

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

?>
</body>
</html>



I hope someone looks at this. I have having an awful time and have tried many diff ways of doing this. The problems seems to be just after my first link. I am also having trouble getting the other post to work as html, some I can get .php.

 

 (#222 2003-09-17 01:18:22) Post Reply
Page 0 1 2 3 4 5

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

I have tried your php.

In the switch case.



case0:



case 0:




 

 (#223 2003-09-17 01:20:17) Post Reply
Page 0 1 2 3 4 5

Shrek
Need To Set


Enrolled: Aug 2003
Posts: 33
AP: 1

I have made a mistake for reply the message.

case0: should change to case 0:
case1: should change to case 1:
.
.
.
Hope this can help u.

 

 (#226 2003-09-17 04:20:25) Post Reply
Page 0 1 2 3 4 5

MarcusD79
Need To Set


Enrolled: Sep 2003
Posts: 10
AP: 1



<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

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



Thanks for you input Shrek, but it seems to still not work. Do you know if the Principal still comes on here?

 

  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