<?php /** * Created by PhpStorm. * User: Yu * Date: 2015/4/8 * Time: 11:12 */ require_once 'market.php'; require_once '../system/debug_off.php'; $conn = dbConnect(); load_market($conn); print_table(GOODS_TABLE); print_table(MARKET_TABLE); $conn = dbConnect(); $res = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM status")); date_default_timezone_set('PRC'); echo "Last Refresh:" . $res['last_refresh']; echo "</br>Unix Time:" . strtotime($res['last_refresh']); echo "</br>Cur:" . date("H:i:s", time()); echo "</br>Elapsed:" . (time() - strtotime($res['last_refresh'])); echo "</br>Elapsed Minutes:" . (time() - strtotime($res['last_refresh'])) / 60; $test = need_refresh($conn) == 1 ? 'YES' : "NO"; echo "</br>Need Refresh? " . $test;
{ mysqli_query($conn, "DELETE FROM " . MARKET_TABLE); } function need_refresh($conn) { $res = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM status")); date_default_timezone_set('PRC'); if (time() - strtotime($res['last_refresh']) > 60) { //echo "test:".(time() - strtotime($res['last_refresh'])); return 1; } else { return 0; } } $connection = dbConnect(); if (need_refresh($connection) == 1) { load_market($connection); load_rank_lists($connection); set_last_refresh($connection); } else { } //SHOULD JUMP TO HOME PAGE HERE //TODO $res = mysqli_query($connection, "SELECT name, price, goods_id FROM " . MARKET_TABLE . " WHERE place_id = 3"); $n = mysqli_num_rows($res); $arr = array(); for ($i = 0; $i < $n; $i++) { $row = mysqli_fetch_array($res); $name = $row['name']; $price = $row['price']; $goods_id = $row['goods_id'];