<?php

function insert_get_member_messages_count($var)
{
        global $conn;
        $query="SELECT count(*) as total FROM messages_inbox WHERE MSGTO='".mysql_real_escape_string($var[USERID])."'";
        $executequery=$conn->execute($query);
        $results = $executequery->fields[total];
		echo "$results";
}

function insert_get_member_unread_messages_count($var)
{
        global $conn;
        $query="SELECT count(*) as total FROM messages_inbox WHERE MSGTO='".mysql_real_escape_string($var[USERID])."' AND unread='1'";
        $executequery=$conn->execute($query);
        $results = $executequery->fields[total];
		echo "$results";
}

function insert_get_msg_sent_time($a)
{
	global $conn;
	$query="SELECT time FROM messages_inbox WHERE MID='$a[mid]'";
	$executequery=$conn->execute($query);
	$timeadded = $executequery->fields[time];
	echo date('Y-m-d', $timeadded);
}

function insert_get_msg_received_time($a)
{
	global $conn;
	$query="SELECT time FROM messages_sent WHERE MID='$a[mid]'";
	$executequery=$conn->execute($query);
	$timeadded = $executequery->fields[time];
	echo date('Y-m-d', $timeadded);
}

?>