title: If condition from database
body: <p>I am getting $final value from database and displaying in a table according to user. Now I have a value i.e., this is I was showing in the frontend</p>
  
  <pre><code>Userid   Total   Letter
    36       45
    5        67
    78       90
    42       82
    12       57
  </code></pre>
  
  <p>Back End Code</p>
  
  <pre><code>$sql = mysql_query('SELECT userid, total FROM history');
  echo '&lt;table&gt;&lt;th&gt;Userid&lt;/th&gt;
               &lt;th&gt;Total&lt;/th&gt;
               &lt;th&gt;Grade&lt;/th&gt;
  while($row = mysql_fetch_array($sql))
  {
    echo '&lt;tr&gt;&lt;td&gt;'.$row['userid'].'&lt;/td&gt;  
              &lt;td&gt;'.$row['$total'].'&lt;/td&gt; 
               $letter = mysql_query('SELECT score,letter FROM letter');               
               while($row = mysql_fetch_array($letter))
               {
                 $score= $row['score'];
                 $letterp= $row['letter']; 
                 switch($row['$total']) 
                {
                  case $row['$total'] == $score;
                  echo '&lt;td&gt;'.$letterp.'&lt;/td&gt;';
                  break;
                  case $row['$total'] &gt;= $score;
                  echo '&lt;td&gt;'.$letterp.'&lt;/td&gt;';
                  break;
                }                
          &lt;/tr&gt;    
  }
  I have a letter table 
   ID  SCORE    letter
    1   100        A+
    2   90         A-
    3   80         B+
    4   73         B-
    5   65         C
    6   55         D
    7   45         E
    8   0          F
  </code></pre>
  
  <p>Switch case is a sample I wrote here. I need to give condition like if userid scores 45 then I need to show letter E and if userid scores 67 then I need to show B-(b'coz the scorefield defines 65 to 54 is B-) . This is the exact requirement.</p>