Example #1
0
    }
}
$db = new MyDB();
if (!$db) {
    echo $db->lastErrorMsg();
}
$type = $_GET['type'];
if ($type == "top3") {
    getTop3($db);
}
if ($type == "rank") {
    getRank($db);
}
if ($type == "timeline") {
    $pagenum = $_GET['page'];
    getPageN($pagenum, $db);
}
function getRank($db)
{
    $userid = $_SESSION['users'];
    $nowdate = date('Y-m-d', time());
    $datetime = strtotime(date("Y-m-d", time()));
    //获取当前日期并转换成时间戳
    $tomorrow = date('Y-m-d', $datetime + 86400);
    //在时间戳的基础上加一天(即60*60*24)
    $searchsql = "Select userid,sum(calorie) as allcal from Exercise where ( userid='{$userid}' or userid in (select friendid from Friendship where userid = '{$userid}')) and endTime<'{$tomorrow}' and endTime>='{$nowdate}' group by userid order by allcal desc";
    $result = $db->query($searchsql);
    $count = 1;
    while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
        if ($userid == $row['userid']) {
            echo $count;
Example #2
0
session_start();
class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open('../../fitdayDB.db');
    }
}
$db = new MyDB();
if (!$db) {
    echo $db->lastErrorMsg();
}
$type = $_GET['type'];
if ($type == "list") {
    $page = $_GET['page'];
    getPageN($page, $db);
}
if ($type == "hot") {
    getHot($db);
}
if ($type == "detail") {
    $id = $_GET['id'];
    getActivity($id, $db);
}
if ($type == "join") {
    $id = $_GET['id'];
    joinActivity($id, $db);
}
if ($type == "getjoin") {
    $id = $_GET['id'];
    getJoin($id, $db);