There are two neat little function in the functions_lookups that will pull any field that you want from the products or products_description tables by just passing it the products_id ... and for pulling any field from the categories and categories_description tables ...
For products:
Code:
/*
* Return any field from products or products_description table
* Example: zen_products_lookup('3', 'products_date_added');
*/
function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id ='" . (int)$product_id . "'
and pd.language_id = '" . (int)$language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
For categories:
/*
* Return any field from categories or categories_description table
* Example: zen_categories_lookup('10', 'parent_id');
*/
function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$category_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id ='" . (int)$categories_id . "'
and cd.language_id = '" . (int)$language . "'");
$return_field = $category_lookup->fields['lookup_field'];
return $return_field;
}
However, there is a little bug in these that you will want to update:
For products:
Code:
/*
* Return any field from products or products_description table
* Example: zen_products_lookup('3', 'products_date_added');
*/
function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id ='" . (int)$product_id . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
For categories:
Code:
/*
* Return any field from categories or categories_description table
* Example: zen_categories_lookup('10', 'parent_id');
*/
function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$category_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id ='" . (int)$categories_id . "'
and c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$language . "'");
$return_field = $category_lookup->fields['lookup_field'];
return $return_field;
}