Avatar of doctorbill
Flag for United Kingdom of Great Britain and Northern Ireland asked on

php loops

I have the following php loop which is working fine on my page:
                $i = "1";      
        do {
      <input type="checkbox" name="pa_it<?php echo $row_orders['ID']; ?>_<?php echo $i; ?>" value="1" class="flip" checked="checked"  />&nbsp;<?php echo $i; ?>

      <?php $i++;} while ($i <= 21 ) ?>

What I need is the following:
1. to introduce a <br> tag when $i is 7 and 14
2. to only check the boxes when a variable is set. I haven't as yet decided on this variable but if someone could give me an idea of what to do I would be very grateful


Avatar of undefined
Last Comment

8/22/2022 - Mon
Chris Stanyon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Try this:

	$i = "1";      
	do { 
		if (($i == 7)||($i == 14)) {
			echo "<br>";
		$box_checked = true; // some variable evaluation here
	<input type="checkbox" name="pa_it<?php echo $row_orders['ID']; ?>_<?php echo $i; ?>" value="1" class="flip" <?php
	echo ($box_checked?'checked="checked"':'');?>  />&nbsp;<?php echo $i; ?>
	} while ($i <= 21 )

Open in new window


Thanks very much
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes