jbrevell Posted March 3, 2004 Share Posted March 3, 2004 Using Cord Focke's Warengruppe contribution I've created a new table of custom classes for products (which are referenced by a new field product_class_id in table PRODUCTS) I would like to display this class on the products.php description page. My PHP only extends to selecting from 1 table so I can display the product_class_id, but I'd like the user-friendly text!... could anyone help? Thanks guys John Quote Link to comment Share on other sites More sharing options...
jbrevell Posted March 3, 2004 Author Share Posted March 3, 2004 slight mistake... it's the products_info.php page I would like to see it on. Quote Link to comment Share on other sites More sharing options...
jbrevell Posted March 3, 2004 Author Share Posted March 3, 2004 OK got the fix from the man himself: I think what you need is a join with the table TABLE_PRODUCTS_CLASS like this: (i marked the new code with ***(new code)*** $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, ***pc.products_class_title*** from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd ***, " . TABLE_PRODUCTS_CLASS . " pc*** where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id *** and p.products_class_id = pc.products_class_id*** and pd.language_id = '" . (int)$languages_id . "'"); (didnt tried out, but should work) Now you should be able to display the name of the products_class: echo $product_info['products_class_title']; This worked fine when: Had to add define('TABLE_PRODUCTS_CLASS', 'products_class'); to /includes/database_tables.php Nothing then displayed as the first products_class_id in products_class was 1, where most of the sample products was 0. inserted another row in products_class with products_class_id = 0 etc. and it worked perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.