Hey everyone,
I'm having an undefined variable error where I have marked in red. The variables i and f2 are defined in another method somewhere else in the code. Please tell me how to fix these errors. Thanks in advance!!
function showDateBox()
{
$startDate = array();
$endDate = array();
$dayarray = array();
$day=date("N");
if($day==7)
{
$startDate[0] = $day;
$endDate[0] = date('Y-m-d',strtotime('next Saturday'));
echo ($startDate[0]." to ".$endDate[0]."<br>");
}
else
{
$startDate[0] = date('Y-m-d',strtotime('previous Sunday'));
$endDate[0] = date('Y-m-d',strtotime('next Saturday'));
//echo ($startDate[0]." to ".$endDate[0]."<br>");
}
for($w=1;$w<=5;$w++)
{
$startDate[$w] = date('Y-m-d',strtotime('next Sunday'.$w.' week'));
$endDate[$w] = date('Y-m-d',strtotime('next Saturday'.($w+1).' week'));
//echo ($startDate[$w]." to ".$endDate[$w]."<br>");
}
echo '<form action="shiftConfirm.php" method="get" name="dateSubmissionForm">';
echo '<select name="startWeek" onchange="submitDate()">';
for($w=0; $w<sizeof($startDate); $w++)
{
if(isset($_GET['startWeek']))
{
if($_GET['startWeek']==$w)
{
$selectedString = "selected = selected";
}
else
{
$selectedString = "";
}
}
else
{
$selectedString = "";
}
echo '<option value="'.$w.'"'.$selectedString.'>'.$startDate[$w]." to ".$endDate[$w]. '</option>';
$day1 = date("Y-m-d", strtotime("+0 day", $startDate[$w]));
$day2 = date("Y-m-d", strtotime("+1 day", $startDate[$w]));
$day3 = date("Y-m-d", strtotime("+2 day", $startDate[$w]));
$day4 = date("Y-m-d", strtotime("+3 day", $startDate[$w]));
$day5 = date("Y-m-d", strtotime("+4 day", $startDate[$w]));
$day6 = date("Y-m-d", strtotime("+5 day", $startDate[$w]));
$day7 = date("Y-m-d", strtotime("+6 day", $startDate[$w]));
$dayarray = array($day1, $day2, $day3, $day4, $day5, $day6, $day7);
}
echo '</select>';
echo '</form>';
}
//this function will go through the days for each individual shift name and if they are within the specified day period, it will add the information to an array to use for later.
function goThroughDays()
{
$valuearray = array();
$locationarray = array();
$ps = 0;
$u = 0;
if($fortitle == 0)
{
$u = 0;
$ps = 0;
for($l = 0; $l<=6; $l++)
{
if($dayarray[$l] == [COLOR="red"]$f2[/COLOR])
{
$valuearray[$u]= [COLOR="red"]$f2[/COLOR];
$locationarray[$ps]=[COLOR="red"]$i[/COLOR];
$ps++;
$u++;
}
}
}
for($l = 0; $l<=6; $l++)
{
if([COLOR="Red"]$dayarray[/COLOR][$l] == [COLOR="red"]$f2[/COLOR])
{
$valuearray[$u]= [COLOR="red"]$f2[/COLOR];
$locationarray[$ps]=[COLOR="red"]$i[/COLOR];
$ps++;
$u++;
}
}
}