View Full Version : Question for davidj and his echoing results php vid

03-25-2007, 06:44 PM
Hey David,

I'm new here and I first would like to say thanks. This is great stuff and I'm learning a lot. I've read two books but have gotten the best understanding from you vids.

I do have 1 question. When we enter the do while loop I understand the reason for it and how it works, but I don't understand the syntax for it.

<?php do { ?>
<td><?php echo $row['field1_id'];?></td>
<td><?php echo $row['field2'];?></td>
<td><?php echo $row['field3'];?></td>
<td><?php echo $row['field4'];?></td>
<?php }while ($row = mysql_fetch_array($result)); ?>

Why is it that when you start the do while loop you open the php and then just place the do{ then close it? I know that if you don't do that it wont run I've tested it many times different ways. I'm just curious to why you need to close it before the loop is finished.

Thanks...again great stuff 8-)

03-26-2007, 12:45 PM
you are not closing the loop just the PHP

You are allowing the php to render pure HTML after the curly brace. If you didnt do that you would have to echo all the html line by line if you didnt escape the PHP

does this make it clearer?

03-26-2007, 02:50 PM
yes it does...thank you