[FX.php List] Split results into two columns

Jonathan Schwartz jschwartz at exit445.com
Thu Aug 27 08:17:45 MDT 2009


I think the key (no pun) is to create the content first and then 
display when done.

How about this:

Option 1:
Process the found set with the standard foreach(), test for odd/even 
records, build the even and odd record tables first and then display 
them after they are complete.

Option 2:
Process the found set with a for(), alternating left and right 
columns by testing for even/odd $key, building them first and then 
displaying, as above.

This is just the broad stroke.

J


>Hi all
>
>I have a confession to make.  I use this code alot, but I don't 
>actually understand how it works.
>
><http://pastebin.com/m7cb20894>http://pastebin.com/m7cb20894
>
><?php
>$i=0;
>$half = (int) ($catResult['foundCount']/2 + 0.5);
>
>foreach ($catResult['data'] as $key => $catData)
>{
>if($i == $half && $i > 10)
>{
>?>
>             </table>
>       <td valign="top">
>             <table border="1">
><?php
>}
>
>?>   
>     <tr>
>         <td>
>             <img src="<?php echo $catData['PhotoURL'][0];?>" width="120"></td>
>         <td><?php echo $catData['Full Name'][0];?><br>
>         <?php echo $catData['UserName'][0];?><br>
>         <?php echo $catData['Export Title'][0];?><br>
>         <?php echo $catData['Level Number'][0];?> <?php echo 
>$catData['Calc Group Short'][0];?>
>         </td>
>              
>     </tr>
><?php
>$i++;
>}
>}
>?>
>
>
>
>The result is half the found set is in one table row that the other 
>half in another.
>
>This works well in most situations, but I have a photobook where I 
>want two columns but I would like the odd records in the left and 
>the even records in the right so that the photo book flows with all 
>the A's then all the B's etc
>
>Does this make sense?  Is what I want possible?
>
>Thanks in advance
>
>Stephen
>
>
>start: 0000-00-00 end: 0000-00-00
>
>Find local businesses and services in your area with Yahoo!7 Local. 
>< 
>http://au.rd.yahoo.com/search/local/mailtagline/*http://local.yahoo.com.au> 
>Get started.
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list


-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20090827/fc2cbcb2/attachment.html


More information about the FX.php_List mailing list