[FX.php List] PHP Question

Steve Hannah shannah at sfu.ca
Thu Jul 20 11:19:37 MDT 2006


Along the same lines but using the modulus operator...

$counter=0;
echo '<table>';
foreach ($foundSet['data'] as $key=>$foundData){
     if ( $counter % 3 == 0 ) echo '<tr>';
     echo '<td width="33%"> Your stuff here</td>';
     if ($counter % 3 == 2) echo '</tr>';
     $counter++;
}
echo '</table>';
On 20-Jul-06, at 10:12 AM, Bob Patin wrote:

> While I've not done it, I know how I would go about this:
>
> $counter = 4;
> foreach($foundSet['data'] as $key=>$foundData){
> 	if ($counter = 4){
> 		$counter = 0;
> 		?>
> 		<?php
> 		<tr> //create a new table row
> 		?>
> 	<?php
> 	}
> 	if ($counter < 4){
> 	?>	
> 		<td width=33%>... create your new column, specify column width  
> here as well (I assume it'd be 33%)
> 		$counter = $counter + 1;
> 	<?php
> 	}
> }
> ?>
>
> This might need tweaking; I just dashed this off, but I think this  
> would work fine...
>
> Let me know how it goes...
>
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
>
>   CONTACT US VIA INSTANT MESSAGING:
>      AIM or iChat: longterm1954
>      Yahoo: longterm_solutions
>      MSN: tech at longtermsolutions.com
>      ICQ: 159333060
>
>
>
> 	
>
>
>
>
> So essentially you'd have a loop within a loop; the main loop is  
> looping through the found set. The internal loop creates columns (3  
> at the max for your example), then exits the loop to start a new row.
>
>
>
> On Jul 20, 2006, at 11:56 AM, David Tinoco wrote:
>
>> I guess this is more a php question, but does anyone know how to  
>> write a piece of code that could write the html for the foundcount  
>> of a query from the database in columns, as well as rows?
>>
>> For example:
>>
>> Category1            Category2                  Category3
>> Category4            Category5                  Category6
>>
>> Instead of:
>>
>> Category1
>> Category2
>> Category3
>> Category4....and so on.
>>
>> Thanks!
>> David
>>
>> With MSN Spaces email straight to your blog. Upload jokes, photos  
>> and more. It's free! It's free!
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060720/c75e3314/attachment.html


More information about the FX.php_List mailing list