part of code is ignored on last loop

I am new to PHP and programming in general. I have looked through the forum and searched all over the web for answers, got help from a serious programmer friend (not a php programmer though) and still have one issue that I can’t seem to solve. I am hoping it is some simple quirk that I am just not aware of.

I wrote a program to take a txt file and display the data in a variety of ways in the browser window. Everything is working fine with one exception. At the end, I use a while loop to echo html code which will display all my data. On the last pass through the loop, it seems like some of the code is just being ignored. I currently have it set to echo 2 line breaks at the end of each loop to make space before writing out the data for the next loop. It works on all but the last one, and any code that runs after all the loops actually gets displayed above or on top of the last loop (such as echoing my date variable. The page is here: mlkap.com/reptrak.php and here is the php code section that I’m having issues with:
[php]<?php
$counter_display = 0;
do
{
echo "






";
$counter_display++;

}
while ($counter_display < count($salesreps_all));

echo “

”.$date."

";

?>[/php]

Thanks for any help and I promise to return the favor if my skills ever get to the point where I can.
-Matt

“.$salesrep_namesinorder[$counter_display].”

".$salesrep_ordercounttoday[$salesrep_namesinorder[$counter_display]]."

Current Orders Current Daily Average Needed Daily Average
“.$salesrep_numoforders[$counter_display].” ".$salesrep_actualdailyaverage[$counter_display]." ".$salesrep_neededdailyaverage[$counter_display]."
Par Number Par Daily Average Month End Quota
“.$salesrep_quotaasofday[$counter_display].” ".$salesrep_quotadailyaverage[$counter_display]." ".$salesrep_quotainorder[$counter_display]."

I noticed you have a

tag echo’ing within your loop… this means that new html table will be created on each iteration of your loop. Is this what you actually want? If so, you need to add a closing tag
at the end of iteration within loop.

In your current code, instead of closing you have this html code:

</td></tr></br></br>

that not really make much sense. Though probably most of modern browsers will close your table, but I’d rather try to produce correct html code.

You definitely need to make sure that all of your tags are closed appropriately as phphelp advised.

Additionally, at the end of each iteration you are incrementing $counter_display. This is going to mean that $counter_display will equal count($salesreps_all) prematurely. There are several ways to fix this, but try using this instead:[php]while ($counter_display <= count($salesreps_all));
[/php]

Thank you guys both so much! I totally overlooked my unclosed table tag. I closed it and the problem is solved.
malasho. thanks for the tip on the while. That’s actually how I had it written at first and changed it to try and solve the problem that was caused by the missing tag.

Again, many thanks. I spent a day trying to figure out something that was so simple. I guess it just takes a fresh set of eyes attached to someone who knows what to look for.

Sponsor our Newsletter | Privacy Policy | Terms of Service