Platinum Games Posted December 5, 2008 Share Posted December 5, 2008 hello all, i am using the new field everywhere contrib, what i would like to do is echo an image depending on the string in the field... eg: if field holds "G" i would like to echo the image G.gif or if field holds "PG" i would like to echo the PG.gif this is what i have so far (please understand i'm not a coder) <?php //BOF NEWFIELD EVERYWHERE if (tep_not_null($product_info['products_ref_const'])) { echo PRODUCTS_REF_CONST.' '.$product_info['products_ref_const']; } //EOF NEWFIELD EVERYWHERE ?><br> <?php //OFLC IMAGE CODE $product_g 'G' $pruduct_pg 'PG' $product_m 'M'; $product_ma 'MA' $product_r 'R' if ($product_info['products_ref_const'] == $product_g}} { echo DR_WS_IMAGE /'oflc/G.gif'. ' ' .$product_info['products_ref_const']; } if ($product_info['products_ref_const'] == $product_pg}} { echo DR_WS_IMAGE /'oflc/PG.gif'. ' ' .$product_info['products_ref_const']; } if ($product_info['products_ref_const'] == $product_m}} { echo DR_WS_IMAGE /'oflc/M.gif'. ' ' .$product_info['products_ref_const']; } if ($product_info['products_ref_const'] == $product_ma}} { echo DR_WS_IMAGE /'oflc/M15.gif'. ' ' .$product_info['products_ref_const']; } if ($product_info['products_ref_const'] == $product_r}} { echo DR_WS_IMAGE /'oflc/R.gif'. ' ' .$product_info['products_ref_const']; } else { echo DR_WS_IMAGES /'oflc/NOT-CLASSIFIED.gif'; } ?><br> <?php //EOF OFLC IMAGE CODE this is the first time i have tried to code so any help would be appreciated. Thanks in advance! Ben Link to comment Share on other sites More sharing options...
burt Posted December 5, 2008 Share Posted December 5, 2008 <?php $images = explode("_", $product_info['products_ref_const']); echo tep_image(DIR_WS_IMAGES . 'oflc/' . end($images) . '.gif'); ?> Might work, might not. That code is untested and straight off the top of my head Link to comment Share on other sites More sharing options...
Platinum Games Posted December 5, 2008 Author Share Posted December 5, 2008 <?php $images = explode("_", $product_info['products_ref_const']); echo tep_image(DIR_WS_IMAGES . 'oflc/' . end($images) . '.gif'); ?> Might work, might not. That code is untested and straight off the top of my head ok so would i replace if ($product_info['products_ref_const'] == $product_g}} { echo DR_WS_IMAGE /'oflc/G.gif'. ' ' .$product_info['products_ref_const']; } with what you put??? how does the code determine what image to get/use??? Thanks in advance! Ben Link to comment Share on other sites More sharing options...
Platinum Games Posted December 5, 2008 Author Share Posted December 5, 2008 got this error! Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Thanks in advance! Ben Link to comment Share on other sites More sharing options...
burt Posted December 5, 2008 Share Posted December 5, 2008 The 2 lines of code I pasted, replaces ALL of the code you came up with. However, as the code I pasted is off the top of my head, it might not work, and I cannot be bothered to test it fully. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.