<?php
$username = "nurturem_root";
$password = "+faH11M@dBxP";
$hostname = "localhost";

# connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");

# select a database to work with
$selected = mysql_select_db("nurturem_smsystem",$dbhandle) or die("Could not select nurturem_smsystem");

# execute the SQL query and return records
$result = mysql_query("SELECT id
                        FROM transaction
                        WHERE NOW() > (subscription_end_on +  INTERVAL 90 DAY)");
# fetch tha data from the database
$arrIds = array();
while ($row = mysql_fetch_array($result)) {
    array_push($arrIds, $row{'id'});
}
echo "<pre>";print_r($arrIds);exit;
# Update the value of Expiry only after the array has some values.
if (count($arrIds) > 0) {
    #Make the array to string by adding comma separated values.
    $strIds = implode(",", $arrIds);
        $strUpdateQuery = "UPDATE transaction
                          SET is_active = '0'
                      WHERE ID IN ($strIds)";
    $result_con = mysql_query($strUpdateQuery);
}
# close the connection
mysql_close($dbhandle);

$to = "phani787@gmail.com";
$subject = "This is subject";
$message = "This is HTML message.";
$header = "From: noreply@example.com\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/plain; charset=utf-8\r\n";
$header.= "X-Priority: 1\r\n";
mail ($to,$subject,$message,$header);

?>