zlack Posted May 5, 2003 Posted May 5, 2003 I want to display the manufacturer in product_info.php. The code i have now is this: <?php $manufacturer_query = tep_db_query("select m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS . " p where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id"); if (tep_db_num_rows($manufacturer_query)) { $manufacturer = tep_db_fetch_array($manufacturer_query); echo $manufacturer; } ?> The result i get is Array What am i doing wrong? Thanks in advance. It's easier to remember, then to forget
zlack Posted May 7, 2003 Author Posted May 7, 2003 Anybody? Please? :( It's easier to remember, then to forget
zlack Posted May 7, 2003 Author Posted May 7, 2003 oops :( only now i notices that after a reply the topic gets higher in the list. sorry :? It's easier to remember, then to forget
Ajeh Posted May 7, 2003 Posted May 7, 2003 This may be more than you are looking for ... but it's handy. Add these define statements to your language file ie /includes/languages/english.php: define('SHOW_MANUFACTURES_TEXT','Manufacture:'); define('SHOW_MANUFACTURES_IMAGE','1'); define('SHOW_MANUFACTURES_NAME','1'); Add this function to your /includes/functions/general.php or favorite function file: //// // BOF: WebMakers.com Added: get manufactures display function tep_get_show_manufactures($product_id) { global $language_id; if ( SHOW_MANUFACTURES_IMAGE=='0' and SHOW_MANUFACTURES_NAME=='0' ) { $show_it=''; } else { $manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m, " . TABLE_MANUFACTURERS_INFO . " mi, " . TABLE_PRODUCTS . " p where p.products_id = '" . $product_id . "' and p.manufacturers_id = m.manufacturers_id and mi.manufacturers_id = m.manufacturers_id"); $manufacturer = tep_db_fetch_array($manufacturer_query); $show_it=''; if ( SHOW_MANUFACTURES_IMAGE=='1' ) { $show_it.=tep_image(DIR_WS_IMAGES . $manufacturer['manufacturers_image'],$manufacturer['manufacturers_name'], '', '', 'vspace="5"'); } if ( SHOW_MANUFACTURES_NAME=='1' ) { $show_it.='<br>' . (($manufacturer['manufacturers_name']) ? SHOW_MANUFACTURES_TEXT . ' ' : '') . $manufacturer['manufacturers_name']; } if ( SHOW_MANUFACTURES_LINK_ON=='1' and ($manufacturer['manufacturers_url']) ) { if ( SHOW_MANUFACTURES_NEW_WINDOW=='1' ) { $show_it= '<a href="' . $manufacturer['manufacturers_url'] . '" target="_blank">' . $show_it . '</a>'; } else { $show_it= '<a href="' . $manufacturer['manufacturers_url'] . '">' . $show_it . '</a>'; } } } return $show_it; } Add this line to your products_info.php where you want to have the manufacture image/name show. I put it above the review stuff: <?php /* WebMakers.com Added: */ include(DIR_WS_INCLUDES . 'manufacturers_display.php'); // Display Manufacturer's Image and Link if set to 1 ?> Edit the select statement at the top of product_info.php to include p.manufacturers_id example: $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, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); This has a few extras to it so you can turn things on/off and use it for other things. But it might help you get the info you are looking for. Example with both image and name turned on: http://www.8thoctave.com/osc_freecall/prod...p?products_id=6
Ajeh Posted May 7, 2003 Posted May 7, 2003 Forgot a peice ... :shock: Create a file manufactures_display.php and put it in the /includes directory: <?php /* WebMakers.com Added: Manufacturer's Image and Link Written by Linda McGrath [email protected] http://www.thewebmakerscorner.com */ // BOF: WebMakers.com Added: Manufacturer's Information if ( (SHOW_MANUFACTURES_IMAGE=='1' or SHOW_MANUFACTURES_NAME=='1') ) { ?> <tr> <td class="main"> <table border="0" align="center"> <tr> <td class="main" align="center"> <?php echo tep_get_show_manufactures($HTTP_GET_VARS['products_id']); ?> </td> </tr> </table> </td> </tr> <?php } // BOF: WebMakers.com Added: Manufacturer's Information ?>
zlack Posted May 7, 2003 Author Posted May 7, 2003 Hi Linda, thanks alot for your reply. But...it doesnt work! :) I did change manufacturers_display.php into manufactures_display.php but i get no output at all. I'm no php guru, so i don't know how to debug and see where it goes wrong :( Any ideas where to look? Thanks, zlack It's easier to remember, then to forget
Ajeh Posted May 7, 2003 Posted May 7, 2003 Change the include to require and see if that helps: include(DIR_WS_INCLUDES . 'manufacturers_display.php');
zlack Posted May 7, 2003 Author Posted May 7, 2003 That doesn't help. I tried to add an echo statement in manufacturers_display.php and that did generate an output. So i think the fault should maybe in the function itself? Thanks, zlack It's easier to remember, then to forget
zlack Posted May 7, 2003 Author Posted May 7, 2003 Linda, I tried messing with your function and I did this just to test: // BOF: WebMakers.com Added: get manufactures display function tep_get_show_manufactures($product_id) { global $language_id; $manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m, " . TABLE_MANUFACTURERS_INFO . " mi, " . TABLE_PRODUCTS . " p where p.products_id = '" . $product_id . "' and p.manufacturers_id = m.manufacturers_id and mi.manufacturers_id = m.manufacturers_id"); $manufacturer = tep_db_fetch_array($manufacturer_query); $show_it.='<br>' . (($manufacturer['manufacturers_name']) ? SHOW_MANUFACTURES_TEXT . ' ' : '') . $manufacturer['manufacturers_name']; echo $manufacturer['manufacturers_name']; echo $show_it; return $show_it; } This only displays a <br> And know i'm totally lost :shock: Any idea ? Thanks, zlack It's easier to remember, then to forget
Recommended Posts
Archived
This topic is now archived and is closed to further replies.