<?php

    $item_separator 
"\n";
    
$item_group_size 3;
    
$item_group_separator "<div class='line'></div>\n";
    
$query "SELECT * FROM products ORDER BY hiddenprice ASC";
    
$news_items = array();
    
$news_item_groups = array();
    
    
$resource mysql_query($query) OR die('query failed');
    while(
$r mysql_fetch_assoc($resource))
    {
        
$news_items[] = <<<TEXTBLOCK
                <div class="box-1">
                    <img src="
{$r['imgurl']}" width="220px" height="169px" class="" alt="">
                    <ul class="listbox-1">
                        <li><span>Typ:</span><a href="#">
{$r['typ']}</a></li>
                    </ul>
                      <p class="price">
{$r['pris']} €</p>
                      <div class="fright marg2">
                         <a href="details.php?id=
{$r['id']}" class="button-2">Läs Mer</a>
                      </div>    
                      <div class="clear"></div>
                </div>
TEXTBLOCK;
    }
    foreach(
array_chunk($news_items$item_group_size) as $news_items_group)
    {
        
$news_item_groups[] = implode($item_separator$news_items_group);
    }
    echo 
implode($item_group_separator$news_item_groups);
?>