title: How to compare two CodeIgniter query results
body: <p>I have a table named SLA and some columns named harian(float), bulanan(float), progres(varchar). I need to update <code>progres</code> column to <code>green</code>, <code>yellow</code>, or <code>red</code> based on the value of the previous month.</p>
  
  <p>Here is the code that I have tried</p>
  
  <pre><code>$id = $this-&gt;input-&gt;post('txtId');
  $idminus1 = floatval($id) - 1;
  
  $currentbulanan = $this-&gt;db-&gt;query("SELECT bulanan 
                                      FROM sla 
                                      WHERE id='$id'")
                  -&gt;row();
  
  $previousbulanan = $this-&gt;db-&gt;query("SELECT bulanan 
                                      FROM sla 
                                      WHERE id='$idminus1'")
                  -&gt;row();
  
  if ($currentbulanan &gt; $previousbulanan) { 
      $progres = "green"; 
  }
  if ($currentbulanan &lt; $previousbulanan) { 
      $progres = "red"; 
  } 
  if ($currentbulanan = $previousbulanan) { 
      $progres = "yellow"; 
  }
  </code></pre>
  
  <p>I want to use <code>$progres</code> variable to update the <code>progres</code> column. I have checked that the result of the first query is greater than the result of the second query, but <code>$progres</code> is always <code>yellow</code>. What am I doing wrong?</p>