splitting a set of list results

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 10, 2012   (RSS)

By zaba - April 5, 2012

Hi, I am wanting to split a set of returned results from a db table of 6 returned results, rather than return the results with all the same formatting applied, I want to apply different formatting to each of the returned results. So say for example the first result in the list may have a larger image and larger heading, results 2 and 3 will be smaller and floated to the right of it. Results 4 and 5 will be smaller boxes on top of each other and result 6 will be as result 1 and floated to the right.
This is not a css thing as I can easily build the divs in a fixed layout and assign use thumb 1 or 2 for the different sizes. Its just how do I pull each individual record from a list in order to then assign it to its div formatting. There will be a max of 6 records, each containing an image and heading. The order will be controlled by the cms order dragging mechanism so they would be able to poppulate the grid in the order they have entered them in the cms. To visually explain ive attached a layout. As I say this is not a css layout issue its purely how to break out the code into the individual divs. Any help would be greatly appreciated.
Attachments:

picture-40.png 231K

Re: [Tom P] splitting a set of list results

By zaba - April 10, 2012

Thanks Tom,
Perfect!!

oh, theres a little error in your code in case anyone else needs to use it

// Loop over the records
<?php foreach $records as $key=>$record : ?>

replace with below (just some brackets missing..)

// Loop over the records
<?php foreach ($records as $key=>$record) : ?>