Forum Moderators: coopster

Message Too Old, No Replies

do loop in mail() function

         

hypersound

1:04 am on Feb 5, 2003 (gmt 0)

10+ Year Member



I am wanting to write the following do loop in the the message part of the mail() function. Is this possible?

<?php do {?>
<?php echo ", "; echo $row_prod_bought['prod_desc'];?>
<?php } while ($row_prod_bought = mysql_fetch_assoc($prod_bought));?>

jatar_k

2:26 am on Feb 5, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld hypersound

being that a do...while loop only checks the truth expression at the end of every loop, wouldn't $row_prod_bought['prod_desc'] not be set the first time?

why not just
while ($row_prod_bought = mysql_fetch_assoc($prod_bought)) {
echo ", "; echo $row_prod_bought['prod_desc'];
}

just a thought, you don't need to put <?php?> on every line, once you do <?php it will be parsed until the?>. So one in the beginning and one at the end will work fine and make the code easier to read.