php - How to count rows before while() -


i need count rows before while().

on page there 10 questions. 5 questions on left, 5 questions on right.

it looks this:

<div class="left">   <div>question 1</div> <div>question 2</div> <div>question 3</div> <div>question 4</div> <div>question 5</div> </div> <!-- /left close -->   <div class="right">   <div>question 6</div> <div>question 7</div> <div>question 8</div> <div>question 9</div> <div>question 10</div> </div> <!-- /right close --> 

data getting mysql.

use sample:

<?php   $dir = 'left';  $count = 0;  foreach($data $row):    $count++;    if($count%5==1):    ?>     <div class="<?php echo $dir?>">      <?php      $dir = 'right';    endif;    ?>     <div>question <?php echo $count?></div>    <?php    if($count%5==0 || $count == sizeof($data)):    ?>       </div>     <?php    endif;  endforeach;  ?> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -