dcc Posted September 28, 2005 Posted September 28, 2005 Hello, I have a very large db with many different manufacturers and many different products. I have installed the featured contrib but would like to combine manufacurers name and products name in same drop down box of the admin area. I have tried but can only get manufactures id to appear together with product name and when i try with manufacturers name. It just wont work function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') { global $currencies, $languages_id; if ($exclude == '') { $exclude = array(); } $select_string = '<select name="' . $name . '"'; if ($parameters) { $select_string .= ' ' . $parameters; } $select_string .= '>'; $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_stocknumber, p.manufacturers_id from " . TABLE_PRODUCTS . " p," .TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '". $languages_id . "' order by products_stocknumber" ); while ($products = tep_db_fetch_array($products_query)) { if (!tep_in_array($products['products_id'], $exclude)) { $select_string .= '<option value="' . $products['products_id'] . '">' . $products['manufacturers_id'] . '??' . $products['products_stocknumber'] . '??(' . $products['products_name'] . ')</option>'; } } $select_string .= '</select>'; return $select_string; } Any ideas? Thanks
kgt Posted September 28, 2005 Posted September 28, 2005 It depends on what you want this to look like. Do you want it to be a dropdown like this: Manufacturer 1 --Product1 --Product2 Manufacturer2 --Product3 --Product4 or like this: Manufacturer 1 - Product1 Manufacturer 1 - Product2 Manufacturer 2 - Product3 Manufacturer 2 - Product4 Right now, it looks like you're going for the second one. Try something like this (completely untested) code: $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_stocknumber, m.manufacturers_name from " .TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id where p.products_id = pd.products_id and pd.language_id = '". $languages_id . "' order by products_stocknumber" ); while ($products = tep_db_fetch_array($products_query)) { if (!tep_in_array($products['products_id'], $exclude)) { $select_string .= '<option value="' . $products['products_id'] . '">' . $products['manufacturers_name'] . ' ' . $products['products_stocknumber'] . ' (' . $products['products_name'] . ')</option>'; } } Contributions Discount Coupon Codes Donations
dcc Posted September 28, 2005 Author Posted September 28, 2005 I have tested your code and it works exactly the why i needed.. Many thanks It depends on what you want this to look like. Do you want it to be a dropdown like this: Manufacturer 1 --Product1 --Product2 Manufacturer2 --Product3 --Product4 or like this: Manufacturer 1 - Product1 Manufacturer 1 - Product2 Manufacturer 2 - Product3 Manufacturer 2 - Product4 Right now, it looks like you're going for the second one. Try something like this (completely untested) code: $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_stocknumber, m.manufacturers_name from " .TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id where p.products_id = pd.products_id and pd.language_id = '". $languages_id . "' order by products_stocknumber" ); while ($products = tep_db_fetch_array($products_query)) { if (!tep_in_array($products['products_id'], $exclude)) { $select_string .= '<option value="' . $products['products_id'] . '">' . $products['manufacturers_name'] . ' ' . $products['products_stocknumber'] . ' (' . $products['products_name'] . ')</option>'; } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.