Trigger alert when database entries are added, not when they are removed
<p>I have a jQuery script running that makes a periodic AJAX call using the following code. </p>

<pre><code>var a = moment();
var dayOfMonth = a.format("MMM Do");
var timeSubmitted = a.format("h:mm a");
var count_cases = -1;
var count_claimed = -1;

setInterval(function(){
    //check if new lead was added to the db
    $.ajax({
        type : "POST",
        url : "inc/new_lead_alerts_process.php",
        dataType: 'json',
        cache: false,
        success : function(response){

            $.getJSON("inc/new_lead_alerts_process.php", function(data) {

                if (count_cases != -1 &amp;&amp; count_cases != data.count) {
                    window.location = "new_lead_alerts.php?id="+data.id;
                }
            count_cases = data.count;
            });
        }
    });
</code></pre>

<p>This is the PHP that runs with each call: </p>

<pre><code>$count = mysql_fetch_array(mysql_query("SELECT count(*) as count FROM leads"));
$client_id = mysql_fetch_array(mysql_query("SELECT id, client_id FROM leads ORDER BY id DESC LIMIT 1"));

echo json_encode(array("count" =&gt; $count['count'], "id" =&gt; $client_id['id'], "client_id" =&gt; $client_id['client_id']));
</code></pre>

<p>I need to change the code so that the alert only triggers when a new entry is added to the database, not when an existing entry is removed. As it stands, the alert fires on both events.</p>

<p>Any help is greatly appreciated. </p>
