Jump to content

[SOLVED] If statments trouble


Clancy19

Recommended Posts

Can someone please help me fix this coding.

 

if ($total=="'10' "or" '9'") 

{

  echo  "<td><p><font face=arial color=red  size=7>Excellent <br></font>";

}

 

if ($total=="'8' "or" '7' "or" '6'") {

echo  "<td><p><font face=arial color=red  size=7>Great <br></font>";

}

 

if ($total=="'5' "or" '4' ") {

echo  "<td><p><font face=arial color=red  size=7>Good <br></font>";

}

 

 

if ($total=="'3' "or" '2' "or" '1' "or" '0'") {

echo  "<td><p><font face=arial color=red  size=7>Better Luck Next Time <br></font>";

}

 

 

When I use this code it echos everything, no matter what $total is. How can i make this work so it only echos one statement depending on what $total is? 

Link to comment
Share on other sites

<?php

$total=5;

if ($total== 10 || $total==9)  {
   echo  "<td><p><font face=arial color=red  size=7>Excellent <br></font>";
   exit;
}


if($total== 8 || $total== 7   || $total== 6 )   {

   echo  "<td><p><font face=arial color=red  size=7>Great <br></font>";
   exit;
}


  if ($total== 5 ||$total==4 )   {
   echo  "<td><p><font face=arial color=red  size=7>Good <br></font>";
   exit;
   
   }
   
   
   if ($total== 3 || $total==2 ||  $total== 1   ||   $total==0  )   {
echo  "<td><p><font face=arial color=red  size=7>Better Luck Next Time <br></font>";
exit;
   }
?>

Link to comment
Share on other sites

with a switch .

 

<?php

$total=5;


switch ($total){

case 10:
case 9:
{
echo  "<td><p><font face=arial color=red  size=7>Excellent <br></font>";
exit;
}


case 8: 
case 7: 
case 6:

{
echo  "<td><p><font face=arial color=red  size=7>Great <br></font>";
exit;
}


case 5:
case 4: 

{
echo  "<td><p><font face=arial color=red  size=7>Good <br></font>";
exit;
}
   
case 3:
case 2: 
case 1: 
case 0:  
   
{
echo  "<td><p><font face=arial color=red  size=7>Better Luck Next Time <br></font>";
exit;
}
   
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.