Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    55
    Plugin Contributions
    0

    Default Need Help With If Statement For Displaying Images

    I am trying to come up with a way to display an image based on the value of a field in the database for each product. For example if the field's value is E, it would display the image for E. If the value was T, it would display the image for T, and so forth. Here is what I have so far code-wise:

    Code:
    <?php /*
    	if ($_GET['esrb_rating'] == "EC") 
    		{
    			echo '<img src="/esrb/ec_esrb.jpg" width="122" height="88" alt="Early Childhood ESRB Rating">';
    		}
    	else {
    		if ($_GET['esrb_rating'] == "E") 
    		{
    			echo '<img src="/esrb/e_esrb.jpg" width="122" height="88" alt="Everyone ESRB Rating">';
    		
    		}
    	}
    	else {
    		if ($_GET['esrb_rating'] == "E10+") 
    		{
    		
    			echo '<img src="/esrb/e10_esrb.jpg" width="122" height="88" alt="Everyone 10+ ESRB Rating">';
    		
    		}
    	}
    	else {
    		if ($_GET['esrb_rating'] == "T") 
    		{
    		
    			echo '<img src="/esrb/t_esrb.jpg" width="122" height="88" alt="Teen ESRB Rating">';
    		
    		}
    	}
    	else {
    		if ($_GET['esrb_rating'] == "M") 
    		{
    		
    			echo '<img src="/esrb/m_esrb.jpg" width="122" height="88" alt="Mature ESRB Rating">';
    		
    		}
    	}
    	else {
    		if ($_GET['esrb_rating'] == "AO") 
    		{
    		
    			echo '<img src="/esrb/ao_esrb.jpg" width="122" height="88" alt="Adults Only ESRB Rating">';
    		
    		}
    	}
    	else {
    	if ($_GET['esrb_rating'] == "RP") 
    		{
    		
    			echo '<img src="/esrb/rp_esrb.jpg" width="122" height="88" alt="Rating Pending ESRB Rating">';
    		
    		}
    	}	
    	else {
    	}*/
    	?>
    I have no idea if I even coded this correctly. I borrowed the idea from someone else, so not sure if I'm doing it correctly or not. Thanks for any help.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Need Help With If Statement For Displaying Images

    Try using:

    Code:
    	switch($_GET['esrb_rating']) {
    	  case 'EC':
          echo '<img src="/esrb/ec_esrb.jpg" width="122" height="88" alt="Early Childhood ESRB Rating">';
          break;
    	  case 'E':
    			echo '<img src="/esrb/e_esrb.jpg" width="122" height="88" alt="Everyone ESRB Rating">';
          break;
    	  case 'E10+':
    			echo '<img src="/esrb/e10_esrb.jpg" width="122" height="88" alt="Everyone 10+ ESRB Rating">';
          break;
        case 'T':
    			echo '<img src="/esrb/t_esrb.jpg" width="122" height="88" alt="Teen ESRB Rating">';
          break;
        case 'M':
    			echo '<img src="/esrb/m_esrb.jpg" width="122" height="88" alt="Mature ESRB Rating">';
          break;
        case 'AO':
    			echo '<img src="/esrb/ao_esrb.jpg" width="122" height="88" alt="Adults Only ESRB Rating">';
          break;
        case 'RP':
    			echo '<img src="/esrb/rp_esrb.jpg" width="122" height="88" alt="Rating Pending ESRB Rating">';
          break;
       }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Please help displaying images with CSS
    By SeánT in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 26 Sep 2010, 02:40 PM
  2. Help! Need to find the CSS for 'Displaying 1 to 3'
    By lazschu in forum Basic Configuration
    Replies: 4
    Last Post: 29 Sep 2008, 03:04 PM
  3. Custom inventory query statement - Need help please
    By 0be1 in forum General Questions
    Replies: 11
    Last Post: 30 May 2008, 02:32 AM
  4. need help with displaying products plz..
    By Pariseau in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 28 Feb 2008, 09:01 PM
  5. need help with new product type for download images
    By ashishgandhi in forum Setting Up Categories, Products, Attributes
    Replies: 11
    Last Post: 19 Feb 2008, 10:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR