Ok, so the assignment is to make a program that lets the user display 3 different kinds of greeting trees. My teacher gave us part of the code and i dont think I quite filled it in right.
Heres the link to how it should work: http://gaia.ecs.csus.edu/~mei/10/LPA/LPA4/Greeting_tree.php
And my broken code part 1:
<HTML>
<HEAD>
<TITLE>Happy Holidays from Csc10</TITLE>
</HEAD>
<BODY bgcolor="#BDEDFF">
<H2>Season's Greetings from Csc10</H2>
<?php
/*
The holidays are just around the corner and we probably have not bought gifts for our family yet. So why not give
them the gift of programming! With such functions as being able to put out a traditionally colored tree, a sac state
tree for all our fans out there, and my own personal favorite colors.
*/
include_once("gt_functions.php");
# MAIN-PROGRAM
$title = "Season's Greetings from Csc10";
html_begin ($title, $title);
if ($submit)
{
{
//set up the data in a 2-dimensional array to mark the background
$A = array(array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"),
array("0","0","0","0","0","0","0","0","0","0","0"));
//this array A is 11x11, therefore the center of a row is 5
$N = 11;
$center = 5;
//mark tree leaves
for ($i=0; $i < 5; $i++)
{
for($j= ($center - $i); $j<= ($center + $i); $j++)
{
$A[$i+2][$j]= "*";
}
}
//mark tree trunk
for ($i = 7; $i < 10; $i++)
{
$A[$i][$center] = "*";
}
//display elements of the array in colors of the tree type
for ($i=0; $i< $N; $i++)
{
for($j=0; $j< $N; $j++)
{
DisplayChar ($type, $A[$i][$j]);
}
echo "<BR>";
}
DisplayGreeting($type);
}
}
//Form to collect user input: one of the 3 greeting tree types
?>
<FORM METHOD="post" ACTION="Greeting_tree.php">
<p><font face="Tahoma" size="2"><b>Pick your tree from the following:</b></font><br></P>
<p><font face="Tahoma" size="2">
<input TYPE="radio" NAME="type" VALUE="Holiday">Holiday Colors
<input TYPE="radio" NAME="type" VALUE="SacState">SacState Colors
<input TYPE="radio" NAME="type" VALUE="Surprise">Surprise Me
</b></font><br>
</p>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Happy Holidays~!"></p>
</FORM>
</BODY></HTML>
</FORM>
<? html_end () ?>
And gt_functions:
<?php
# A collection of functions that will be included in Greeting_tree.php
function html_begin ($title, $header)
function DisplayChar ($type, $char)
//display leaf color when $char = "*" and background color when $char = "0" according to given tree type
{
if ($type =="Holiday")
{
if ($char =="0")
{echo ("Font face =\"tahoma\"size2\"#7E2217)
elseif ($char =="*")
{echo ("Font face =\"tahoma\"size2\"#347235)
}
}
{
elseif ($type =="SacState")
{
if ($char =="0")
{echo("<font face=\"Tahoma\" size=\"2\" color=\"#347235">);
elseif ($char =="*")
{echo (<font face=\"Tahoma\" size=\"2\" color=\"#AF7817">);
}
}
{
elseif ($type =="Surprise")
{
if ($char =="0")
{echo ("Font face =\"tahoma\"size2\"#000000)
elseif ($char =="*")
{echo ("Font face =\"tahoma\"size2\"#E56717)
}
}
function DisplayGreeting ($type)
//display greeting message according to given tree type
{
if ($type == "Holiday")
$type="Season's Greetings!"
echo("<font face="BRUSH SCRIPT MT" size="2"></font><br>")
}
{
elseif ($type =="SacState")
$type="Happy Holidays from Sacramento State!"
echo("<font face="Century Gothic" size="2"></font><br>")
}
{
elseif ($type =="Surprise")
$type="It took me two months to say Happy Halloween."
echo("<font face="Edwardian Script ITC" size="2"></font><br>")
}
?>
function html_end ()