I recommend doing a single query rather than a separate query for each product. For example (untested):
PHP Code:
$mids = array();
foreach ($products as $p)
$mids[] = $p['manufacturerid'];
if (!empty($mids)) {
$manufacturers = func_query_hash("SELECT manufacturerid,manufacturer FROM $sql_tbl[manufacturers] WHERE manufacturerid IN(".implode(',',$mids).")",'manufacturerid',FALSE,TRUE);
foreach ($products as $k=>$p)
$products[$k]['manufacturer'] = $manufacturers[$p['manufacturerid']];
}
I'd rather loop through products twice and do a single query than a single loop with multiple queries.