tebrown Posted September 6, 2012 Share Posted September 6, 2012 Hey Guys, I have just created a function where it determines a team color for their profile. Take a look at the photo for an example. This shows their team color next to their names. What im trying to do now is to determine of this player is injured or not. If the player is injured it will replace the team color for the specific person to red. I have given it a go but its not working as expected. Here is the function: function teamcolor($color, $injured) { if ($color == 'Senior As') { echo "<div style='height: 100%; width: 3px; background-color: #DDAB5B;'>"; } if ($color == 'Colts U21s') { echo "<div style='height: 100%; width: 3px; background-color: #C492F4;'>"; } if ($color == 'Senior Bs') { echo "<div style='height: 100%; width: 3px; background-color: #7BCBEF;'>"; } else if ($injured=='1') { echo "<div style='height: 100%; width: 3px; background-color: #cc1717;'>"; } } Calling the function: <?php echo teamcolor($color, $injured); ?> Link to comment https://forums.phpfreaks.com/topic/268047-php-function-help/ Share on other sites More sharing options...
tebrown Posted September 6, 2012 Author Share Posted September 6, 2012 Would this be appropriate? function teamcolor($color, $injured) { if ($injured == '1') { echo "<div style='height: 100%; width: 3px; background-color: red;'>"; } else if ($color == 'Senior As') { echo "<div style='height: 100%; width: 3px; background-color: #DDAB5B;'>"; } else if ($color == 'Senior Bs') { echo "<div style='height: 100%; width: 3px; background-color: green;'>"; } else if ($color == 'Colts U21s') { echo "<div style='height: 100%; width: 3px; background-color: blue;'>"; } } Link to comment https://forums.phpfreaks.com/topic/268047-php-function-help/#findComment-1375636 Share on other sites More sharing options...
requinix Posted September 6, 2012 Share Posted September 6, 2012 Being injured is more important than what team they're on, right? So check for that first. Link to comment https://forums.phpfreaks.com/topic/268047-php-function-help/#findComment-1375637 Share on other sites More sharing options...
tebrown Posted September 6, 2012 Author Share Posted September 6, 2012 Yes it is. So that above code would be correct yes? - checking for the inured first... Link to comment https://forums.phpfreaks.com/topic/268047-php-function-help/#findComment-1375638 Share on other sites More sharing options...
requinix Posted September 6, 2012 Share Posted September 6, 2012 Your indentation is a bit funky but yes. Link to comment https://forums.phpfreaks.com/topic/268047-php-function-help/#findComment-1375645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.