PHP incorrect output with loop

I am trying to construct the correct syntax for a php code, here it is, keeps displaying incorrectly. Any light on this? Thanks!

while ($row=mysql_fetch_array($upcoming))
{
$appid[$n]=$row['ID'];
$appdatetime[$n]=$row['apptdatetime'];
$schedulet[$l]=date('g:i A' , strtotime($appdatetime[$n]));
$schedulea[$l]=date("m/d/Y",strtotime($appdatetime[$n]));
$display .= $schedulea[$l] . "@" . $schedulet[$l] ;
$display .= ". To cancel, click <a href='cancellations.php?quickcancel=yes&id=" . $appid[$n] . '"  here</a><br>\n";
$display .= '</font><font size="2" face="Eras Demi ITC">\n';

if ($row['ID']=="")
{
$display .= '<font size="2" face="Eras Demi ITC">No Future Appointments Scheduled';
}
$n++;
$l++;
}

echo "$display";
jcbodyworksAsked:
Who is Participating?
 
MasonWolfConnect With a Mentor Commented:
Well I see a few issues here.

First, I don't see an initial "<font>" opening tag to go with the first closing tag. Likewise, I don't see a final "</font>" closing tag. However, these are probably both declared outside your loop.

More serious, this line:
$display .= ". To cancel, click <a href='cancellations.php?quickcancel=yes&id=" . $appid[$n] . '"  here</a><br>\n";
does not appear to have a closing ">" on the 'a' tag. That's going to really screw up your page.

Next, I notice in this line:
$display .= '</font><font size="2" face="Eras Demi ITC">\n';
that you have a single-quoted \n. That's not a newline. Inside single quotes it's just a literal slash followed by the letter n. Change to this:
$display .= '</font><font size="2" face="Eras Demi ITC">'."\n";

Finally, why are you reopening the "<font>" tag inside your conditional section?
Seems like you should use:
if ($row['ID']=="")
{
$display .= 'No Future Appointments Scheduled';
}

That's all I see. Maybe there's more. Let me know if your output is still funny-looking. If so, post your revised code and I'll take a look at it.
0
 
gamebitsCommented:
What is it displaying that is incorrect?
0
All Courses

From novice to tech pro — start learning today.