Coming soon to a webpage near you dynamically displaying the daily stellar special using php. I worked on this for about 2 hours today. I'm excited.
Update: The page is up! Check it out. Source code below:
<?php
//guinansgalactic.php
/*
A fictional webpage for Guinan's Galactic Bar & Grill
that dynamically displays the daily special including
name, image, price, and brief description.
Specials are:
Sunday
Gahg
$3
Served very fresh.
Monday
Romulan Ale
$4
The blue, banned moonshine of Romulus in a glass.
Tuesday
Kanar
$3
A Cardi favorite, served neat.
Wednesday
Prune Juice
$2
A warrior's drink.
Thursday
Rokeg Blood Pie
$4
Just like mom use to make on Kronos.
Friday
Samarian Sunset
$3
Made in the traditional style. I hope you enjoy it. I hope you enjoy it.
Saturday
Root Beer
$3
Bubbly and happy, just like the Federation.
*/
$dayOfWeekNum = date('w');
if($dayOfWeekNum == 0)
{
$special = "Gahg";
$price = "3";
$notes = "Served very fresh.";
$image = "gagh.jpg";
}
if($dayOfWeekNum == 1)
{
$special = "Romulan Ale";
$price = "4";
$notes = "The blue, banned moonshine of Romulus in a glass.";
$image = "romulanale.jpg";
}
if($dayOfWeekNum == 2)
{
$special = "Kanar";
$price = "3";
$notes = "A Cardi favorite, served neat.";
$image = "kanar.jpg";
}
if($dayOfWeekNum == 3)
{
$special = "Prune Juice";
$price = "2";
$notes = "A warrior's drink.";
$image = "prunejuice.jpg";
}
if($dayOfWeekNum == 4)
{
$special = "Rokeg Blood Pie";
$price = "4";
$notes = "Just like mom use to make on Kronos.";
$image = "bloodpie.jpg";
}
if($dayOfWeekNum == 5)
{
$special = "Samarian Sunset";
$price = "3";
$notes = "Made in the traditional style. I hope you enjoy it. I hope you enjoy it.";
$image = "samariansunset.jpg";
}
if($dayOfWeekNum == 6)
{
$special = "Root Beer";
$price = "3";
$notes = "Bubbly and happy, just like the Federation.";
$image = "rootbeer.jpg";
}
?>
<html>
<head>
<style>
body{background-color:#9944dd;}
</style>
</head>
<body>
<h1>Guinan's Galactic Bar & Grill</h1>
<img src="images/guinan.jpg" />
<h2><?=date('l')?>'s Special</h2>
<p><b><?=$special?></b><p>
<p>Only $<?=$price?></p>
<img src="images/<?=$image?>" />
<p><?=$notes?></p>
</body>
</html>
No comments:
Post a Comment