Images
-
- Posts: 127
- Joined: Mon Jan 03, 2011 5:38 am
Images
I want to set it up depending on what class they choice they get a different image as their avatar how do I do this?
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Images
You just have to remember that PHP can output anything into the page HTML, and them make a dynamic image tag:
Code: Select all
<img src="<?php
switch ($_SESSION['class']) {
case 'warrior':
echo "images/classpics/warrior.png"; //enter your url here
break;
case 'mage':
echo "images/classpics/mage.png";
break;
case 'rogue':
echo "images/classpics/rogue.png";
break;
default:
//of course throwing exceptions (aka errors) is optional, but if the class isn't what you think, something is very wrong
throw new Exception("Incorrect class data stored.");
break;
} ?>" alt="avatar image" />
The indelible lord of tl;dr