View Single Post
Old 10-31-2012, 07:17 PM   PM User | #2
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
sorted it
PHP Code:
<?php
$xml 
simplexml_load_file('services.xml');

$typesListXml $xml->xpath('service/category');

if (!empty(
$typesListXml)) {
    
$typesList = array();
    foreach (
$typesListXml as $typeXml) {
        
$typesList[] = (string)$typeXml;
    }

    
$typesList array_unique($typesList);

    
$moviesForType = array();
    foreach (
$typesList as $type)
    {
        echo 
"<div class='wrapper'>";
        echo 
"<h3 class='hp-1'>$type</h3>";
        
$rawData $xml->xpath('service[category="' $type '"]');
        if (!empty(
$rawData))
        {
            foreach (
$rawData as $rawMovie)
            {
                
$moviesForType[$type][] = $rawMovie->subcat;
            }
        }
        
        
$moviesForType[$type] = array_unique($moviesForType[$type]);
        
        
$prods = array();
        
$count=1;
        foreach(
$moviesForType[$type] as $key)
        {
            if(
$count %<> 0)
            {
                echo 
"<div class='columns col-padding'>";
            }
            else
            {
                echo 
"<div class='columns'>";
            }
            echo 
"<ul class='price-list'>";
            echo 
"<li class='header price-item-header bold'>$key</li>";
            
$serv $xml->xpath('service[subcat="'$key '"]');
            foreach(
$serv as $serv)
            {
                echo 
"<li><a href='#' class='price-item'>$serv->name</a><span class='price'>£$serv->price</span><span class='filler'>&nbsp;</span></li>";
            }
            echo 
"</ul></div>";
            
$count++;
        }
        echo 
"</div>";
    }
}
?>
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook
LJackson is offline   Reply With Quote