Salvo Posted April 28, 2005 Share Posted April 28, 2005 Hi all, I am trying to get the product with a new function, but it doesn't work. Can someone look at it> thanks function tep_get_products($default = '') { $products_array = array(); if ($default) { $products_array[] = array('id' => '', 'text' => $default); } $products_query2 = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name"); while ($products2 = tep_db_fetch_array($products_query2)) { $products_array[] = array('id' => $products2['products_id'], 'text' => $products2['products_name']); } return $products_array; } Link to comment Share on other sites More sharing options...
Salvo Posted April 28, 2005 Author Share Posted April 28, 2005 Hi all I have found the reason why it wasn't working, but I don't understand why In admin/includes/funcions/genenral.php This doesn't work $products_query = tep_db_query("select p.products_id, pd.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name"); THIS WORKS OK $products_query = tep_db_query("select p.products_id, pd.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id order by products_name"); Can someone tell me why the (int)$languages_id is not picked up? Thanks Link to comment Share on other sites More sharing options...
Jan Zonjee Posted April 28, 2005 Share Posted April 28, 2005 I guess you have to add: global $languages_id; because you are working inside a function. Otherwise the variable is empty and therefore you don't get a result from the query. Link to comment Share on other sites More sharing options...
Salvo Posted April 28, 2005 Author Share Posted April 28, 2005 YESSSSS Thank you it worked Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.