Hi, Please check the below code :
function getDate($campid)
{
global $conn, $agencies;
$return=array(
'date'=>'',
);
$sql = "SELECT tsc_date_completed
FROM tasks_completed
WHERE campid = '".$campid."' AND
tsk_id = 10
ORDER BY id DESC
LIMIT 1";
$r = pg_query($conn,$sql);
if ($r) {
$d = pg_fetch_array($r);
if (!empty($d)) {
$tsc_date = $d[0];
}
}
@pg_free_result($r);
return $tsc_date;
}
Thanks and hope it will help you. :)