<?php 
session_start();
include '../db.php';
error_reporting(0);
include("../all_query.php");
 if(isset($_SESSION['loan_crm_username']) && isset($_SESSION['loan_crm_password']))
{
	
	
 	
	 $advisor_id = $_SESSION['loan_crm_userid'];
	 $login_name = $_SESSION['login_name'];
	
	 
	 
	 
	 
   $today_date = date('Y-m-d');
    
	
	   $sender_id = $_REQUEST['advisor_id'];
	   
	     $advisorQ = mysqli_query($conn,"select *  from `advisors` where id=$sender_id  ");
							   
		 $advisorData = mysqli_fetch_assoc($advisorQ);
					
					
					
	
     $newMessageQ = mysqli_query($conn,"select *from `messages` where ( (sender_id = $sender_id and receiver_id = $advisor_id)  )  and  is_read = 0 ");
	 
	 while($newMessageData = mysqli_fetch_assoc($newMessageQ))
	 {
		  echo "1";
		 
		 $message_id = $newMessageData['id'];
		 
		 mysqli_query($conn,"update `messages` set is_read = 1 where id  = $message_id ");
 
		 
	 }
	
	
	
	
	
	
	
 }
	
	
	?>