View Single Post
  #5  
Old 09-16-2013, 07:17 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Show manufacturer on products_t

Quote:
Originally Posted by PhilJ
PHP Code:
# Get Product Manufacturer
if($products){
    foreach(
$products as $key=> $product)
        
$products[$key]["manufacturerid"] = func_query_first_cell("SELECT manufacturerid FROM $sql_tbl[manufacturers] WHERE manufacturerid=" $product["manufacturerid"]);
        
$products[$key]["manufacturer"] = func_query_first_cell("SELECT manufacturer FROM $sql_tbl[manufacturers] WHERE manufacturerid=" $product["manufacturerid"]);
}
# /Get Product Manufacturer 
The above is not correct. This should work better:
PHP Code:
if($products)
    foreach(
$products as $key=> $product
        
$products[$key]['manufacturer'] = func_query_first_cell("SELECT manufacturer FROM $sql_tbl[manufacturers] WHERE manufacturerid=$product[manufacturerid]"); 
I believe you should already have the list of all manufacturers so there should be no need to do a query to get them. In theory:
PHP Code:
{if $product.manufacturerid}
  {foreach 
from=$manufacturers_menu item=m}
    {if 
$m.manufacturerid eq $product.manufacturerid}
      <
p><a href="manufacturers.php?manufacturerid={$product.manufacturerid}">{$m.manufacturer|amp}</a></p>
    {/if}
  {/foreach}
{/if} 
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote