Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

My first if else statement!


Platinum Games

Recommended Posts

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

<?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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...