true)); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $query = "SELECT date,duration,hit FROM active_index WHERE user_id = ? "; $sth = $dbh->prepare($query); $sth->execute(array($userid)); $last = 0; while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $curr = $last + $row["duration"] / 3600000; $output[] = array($row["date"], round($last, 3), round($curr, 3), round($last, 3), round($curr, 3), $row["hit"]); $last = $curr; } echo json_encode($output); //echo str_replace('"','',$json); }