Jump to content

PHP Function Help


tebrown

Recommended Posts

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

post-132578-1348240376865_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/268047-php-function-help/
Share on other sites

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

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.