title: Send email alert when mySQL field equals a value
body: <p>I have an inventory mySQL database.  I need an email sent to a few people alerting them when the "qty" equals or is less than the number in the "min" field. </p>
  
  <p>Does anyone know how to create a script to have email sent IF the <strong><em>"qty"</em></strong> equals or is less than <strong><em>"min"</em></strong>?  Can this be done on the server-side?</p>
  
  <p>Erik</p>
  
  <pre><code>DATABASE NAME: _hero 
  
  TABLE NAME:  CARTONS_CURRENT
  +--------------+--------------+--------+--------+-------------------+---------+
  | Column       |  Type        |  Null  |  Key   |  Default          |  Extra  |
  +--------------+--------------+--------+--------+-------------------+---------+
  | orig_time    | timestamp    |  No    |        | CURRENT_TIMESTAMP |         |
  | type         | text         |  No    |        |                   |         |
  | part_no      | varchar(20)  |  No    |  Prim  |                   |         |
  | description  | varchar(75)  |  No    |        |                   |         |
  | count        | varchar(2)   |  No    |        |                   |         |
  | size         | varchar(30)  |  No    |        |                   |         |
  | min          | int(7)       |  No    |        |                   |         |
  | max          | int(7)       |  No    |        |                   |         |
  | qty          | int(8)       |  No    |        |                   |         |
  +--------------+--------------+--------+--------+-------------------+---------+
  </code></pre>