function gradlistDisplayFunction()
{
include '../../include/dbview.inc';
$mysqli = new mysqli($hostname, $username, $password, $databasename);
if ($mysqli->connect_error) {
echo "Error connecting to database (".$databasename."), Error: ".$mysqli->connect_error."
";
showerror();
}
$querystr = "SELECT classyearsidway, classyearGIHS, count(*) FROM guestbook WHERE (classyearsidway!='') OR (classyearGIHS!='') GROUP BY classyearGIHS, classyearsidway ORDER BY classyearGIHS, classyearsidway;";
$result = $mysqli->query($querystr);
if ($result->errno) {
echo "Error in query, [".$querystr."], Error: ".$result->error."
";
showerror();
}
echo "
Sidway Graduating Class:";
$count=11;
$GIHSflag=0;
while ($row = $result->fetch_row())
{
if ($count > 10)
{
echo "
";
$count = 0;
}
Else
{
echo "|";
}
if (trim($row[0])!="")
{
echo "".trim($row[0])." (".trim($row[2]).")";
}
else
{
if ($GIHSflag==0)
{
echo "
Grand Island High School Graduating Class:
";
$GIHSflag=1;
}
echo "".trim($row[1])." (".trim($row[2]).")";
}
$count=$count+1;
}
echo "
";
$querystr = "SELECT firstname, maidenname, lastname, edit, showemail, displaymail, classyearsidway, classyearGIHS, resident, ResFrom, ResTill, city, state FROM guestbook WHERE (classyearsidway!='') OR (classyearGIHS!='') ORDER BY classyearGIHS, classyearsidway, lastname;";
$result = $mysqli->query($querystr);
if ($result->errno) {
echo "Error in query, [".$querystr."], Error: ".$result->error."
";
showerror();
}
$year=trim($row[6]);
echo $year."
";
while ($row = $result->fetch_row())
{
$flag=0;
//if the user has a sidway grad year
if (trim($row[6])!="")
{
if (trim($row[6])!=$year)
{
$year=trim($row[6]);
echo "
Sidway Class of ".$year."
";
}
//if the grad year matches the current year
if (trim($row[6])==$year)
{
//if the users entry has been edited
if (trim($row[3])==1)
{
//if the user wants their email address displayed
if (trim($row[4])==1)
{
echo "".trim($row[0]);
if (trim($row[1])!="")
{
echo " '".trim($row[1])."'";
}
echo " ".trim($row[2])." - ";
}
else
{
echo "".trim($row[0]);
if (trim($row[1])!="")
{
echo " '".trim($row[1])."'";
}
echo " ".trim($row[2])." - ";
}
if ((trim($row[8])=="past") || (trim($row[8])=="present"))
{
if ((trim($row[9])!="") && (trim($row[10])!=""))
{
echo "Resident ".trim($row[9])." - ".trim($row[10]);
$flag=1;
}
}
if ((trim($row[11])!="")&&(trim($row[11])!="GI")&&(trim($row[11])!="Grand Island")&&(trim($row[11])!="gi")&&(trim($row[11])!="grand island"))
{
if ($flag==1)
{
echo ", n";
}
else
{
echo "N";
}
echo "ow resides in ".trim($row[11]).", ".trim($row[12]);
$flag=1;
}
if ($flag==0)
{
echo "No Information Provided";
}
echo "
";
}
}
}
//if the user has no sidway grad year, they have a GIHS grad year
else
{
if (trim($row[7])!=$year)
{
$year=trim($row[7]);
echo "
Grand Island High School Class of ".$year."
";
}
//if the grad year matches the current year
if (trim($row[7])==$year)
{
//if the users entry has been edited
if (trim($row[3])==1)
{
//if the user wants their email address displayed
if (trim($row[4])==1)
{
echo "".trim($row[0]);
if (trim($row[1])!="")
{
echo " '".trim($row[1])."'";
}
echo " ".trim($row[2])." - ";
}
else
{
echo "".trim($row[0]);
if (trim($row[1])!="")
{
echo " '".trim($row[1])."'";
}
echo " ".trim($row[2])." - ";
}
if ((trim($row[8])=="past") || (trim($row[8])=="present"))
{
if ((trim($row[9])!="") && (trim($row[10])!=""))
{
echo "Resident ".trim($row[9])." - ".trim($row[10]);
$flag=1;
}
}
if ((trim($row[11])!="")&&(trim($row[11])!="GI")&&(trim($row[11])!="Grand Island")&&(trim($row[11])!="gi")&&(trim($row[11])!="grand island"))
{
if ($flag==1)
{
echo ", n";
}
else
{
echo "N";
}
echo "ow resides in ".trim($row[11]).", ".trim($row[12]);
$flag=1;
}
if ($flag==0)
{
echo "No Information Provided";
}
echo "
";
}
}
}
}
$mysqli->close();
//End for function
}
?>