Actually, I'm learning a bunch of stuff about working with objects and refreshing some of my PHP in general, so it's good for me (if a bit of a headache while I learn:).
I had to tweak the SQL to test it locally, because the pd.products_model_number field does not exist in stock ZC. I substituted products_model from the products table.
It seems that $unique_model is not just an array with products_model and manufacturers_id fields, but a whole stew of stuff, so sizeof() doesn't work on it, returning just 1. You have to use $unique_model->RecordCount() to get that info. That explains why other ZC files do a processing step on query results to put them into a usable array.
My latest version is here, and it appears to work in local testing.
PHP Code:
<?php
//test by gjh42 2010-11-17 - : http://www.zen-cart.com/forum/showthread.php?t=167959 second layout version - now updating in 139fresh
//good for mfr lists that are all large
// /includes/modules/your_template/model_list2.php
// include(DIR_WS_MODULES . zen_get_module_directory(model_list2.php));//put in location file - not working
// include(DIR_WS_MODULES . 'your_template/model_list2.php');//put in location file
$content = '<div id="modelList">' . "\n";
$manufacturers = $db->Execute("SELECT manufacturers_name, manufacturers_id FROM " . TABLE_MANUFACTURERS . " ORDER BY manufacturers_name ASC");
while (!$manufacturers->EOF) {
$unique_model = $db->Execute("SELECT DISTINCT pd.products_model_number, p.manufacturers_id
FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_PRODUCTS . " p
ON pd.products_id = p.products_id
WHERE p.manufacturers_id = '" . $manufacturers->fields['manufacturers_id'] . "'
ORDER BY pd.products_model_number ASC");
//use this for stock zc
//$unique_model = $db->Execute("SELECT DISTINCT products_model, manufacturers_id
// FROM " . TABLE_PRODUCTS . "
// WHERE manufacturers_id = '" . $manufacturers->fields['manufacturers_id'] . "'
// ORDER BY products_model ASC");
$col_count = 0;
$content .= '<div class="mfrList">' . "\n";
$content .= '<h3>' .$manufacturers->fields['manufacturers_name']. '</h3>' . "\n";
$um_size=($unique_model->RecordCount());
if($unique_model->RecordCount()>0) {
$col_max_item = ceil($unique_model->RecordCount()/4);
$content .= '<ul class="first">' . "\n";
while (!$unique_model->EOF) {
if($col_count >= $col_max_item){
$col_count = 0;
$content .= '</ul>' . "\n" . '<ul>' . "\n";
}
$content .= ' <li><a href="index.php?main_page=advanced_search_result&search_in_description=1 keyword=' .$unique_model->fields['products_model_number']. '" alt="alt name" />' .$unique_model->fields['products_model_number']. '</a></li>' . "\n";
$col_count ++;
$unique_model->MoveNext();
}//uniq
$content .= '</ul>' . "\n";
}//size
$content .= '<br class="clearBoth"></div>' . "\n";
$manufacturers->MoveNext();
}//man
$content .= '</div><br class="clearBoth">' . "\n" . '</div>' . "\n";
echo $content;
//EOF
?>
<style>
/*stylesheet rules*/
#modelList {}
.mfrList {margin: 0.5em; padding: 0.5em; border-bottom: 1px solid #aabbcc;}
#modelList h3 {text-align: center;}
#modelList ul {float: left; width: 24.5%; margin: 0; padding: 0; border-left: 1px solid #aabbcc;}
#modelList ul.first {border: none;}
#modelList li {list-style: /*none*/ inside; padding: 0 0 0 1.0em;}
#modelList a {color: #0099cc;}
</style>