=:time"; $array = array(":time" => date("Y-m-d H:i:s", time() - $l)); } $select = $db->prepare("SELECT * FROM sent ".$where); if(!$select->execute($array)) error("Unable to read messages"); $messages = array(); while($msg = $select->fetch()) $messages[] = array("id" => intval($msg['id']), "recipient" => $msg['recipient'], "text" => $msg['text'], "time" => strtotime($msg['time']), "status" => intval($msg['status']), "gate" => intval($msg['gate']), "timeStatus" => $msg['timeStatus'] ? strtotime($msg['timeStatus']) : 0); echo json_encode(array("timestamp" => time(), "messages" => $messages)); ?>