help splitting results into three columns

I have php that currently pulls info from a database and splits it into two columns, with a redesign we’d like this to be split into three columns. Can someone help me rework this code so it will filter the results into three columns.

[php]

<?php echo $alpha;?>

<?php $rs=mysql_query($sql); $total=mysql_num_rows($rs); $half=round($total/2); $i=1; $flag=0; while($row=mysql_fetch_array($rs)){ if($i<=$half){ if($flag==0) { ?>
		  <span class="guideColumn">
            <?php $flag=1;
			}?>	<?php doSnippet($row); ?>
				
				<?php if($i==$half){
				$flag=2;
				        ?></span>	<?php
				}}
				
				if($i>$half){
				 if($flag==2) 
		   {
		 
		  ?>
		  <span class="guideColumn">
            <?php $flag=5;
			}?>	
				
				  
            	<?php doSnippet($row); ?>
				<?php if($i==$total){
				?>
				</span>	<?php 
				}
					
				
                } 
			   $i++;
			    }?> 
        </span>[/php]

Just change the way you do the split… for example

[php]$half=ceil($total/3);[/php]

Then you could do like

[php]if ($i % $half == 0)[/php]

Thanks, this got it working.

Sponsor our Newsletter | Privacy Policy | Terms of Service