title: Checking the SUM of specific column with condition before inserting data
body: <p>I need help! I just want to insert data from user but before that it will check first if the 'dami' column in database is &lt;=100, if yes then it will insert the data entered by the user if no then it will prompt the user.</p>
  
  <p>But with my code it keeps inserting regardless of the 'dami' sum. Badly need it! Here's my code!</p>
  
  <pre><code>public function do_create_businesscard($txttelno,$txttelno1,$txtfaxno,$txtmobileno,$txtmobileno1,$txtemail,$txtemail1,$txtPieces,$is_deleted)
      {
          $sql = "SELECT (SELECT SUM(dami)
                  FROM tbl_business_card_information
                  WHERE is_deleted = 1)
                  AS 'Total'";
  
          if ('Total' &gt;= 100){
          echo "Sorry but you already reach you maximum request";
  
          }else{
  
          $sql = "INSERT INTO tbl_business_card_information (`tel_no`,`tel_no1`,`fax_no`,`mobile_no`,`mobile_no1`,`email`,`email1`,`dami`) VALUES (?,?,?,?,?,?,?,?)";
  
          $data = array($txttelno,$txttelno1,$txtfaxno,$txtmobileno,$txtmobileno1,$txtemail,$txtemail1,$txtPieces);                           
          $query = $this-&gt;db-&gt;query($sql,$data);
          return $query;  
          }
      }
  </code></pre>
  
  <p>Thank You !</p>