PHP incorrect output with loop

Posted on 2007-09-29
Last Modified: 2013-12-13
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))
$schedulet[$l]=date('g:i A' , 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';

echo "$display";
Question by:jcbodyworks
    LVL 28

    Expert Comment

    What is it displaying that is incorrect?
    LVL 13

    Accepted Solution

    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.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now