function requestCurrentPageActivities($startPostion, $uCity, $conn) { global $maxActivityID; $resultsArr = array(); if (showUserActivities($uCity)) { $userCitySql = "SELECT * FROM \n\t\t\t\t\t\t\tjobs_activity\n\t\t\t\t\t\t\tWHERE id<={$maxActivityID}\n\t\t\t\t\t\t\tAND city='{$uCity}'\n\t\t\t\t\t\t\tAND flag=0\n\t\t\t\t\t\t\tORDER BY begin_date ASC;"; $userCityActivitiesResults = $conn->query($userCitySql); if ($userCityActivitiesResults->num_rows > 0) { while ($row = $userCityActivitiesResults->fetch_assoc()) { array_push($resultsArr, $row); } } } $sql = "SELECT * FROM \n\t\t\t\tjobs_activity\n\t\t\t\tWHERE id<={$maxActivityID}\n\t\t\t\tAND city!='{$uCity}'\n\t\t\t\tAND flag=0\n\t\t\t\tORDER BY city_flag ASC,\n\t\t\t\tbegin_date ASC;"; $results = $conn->query($sql); if ($results->num_rows > 0) { while ($row = $results->fetch_assoc()) { array_push($resultsArr, $row); } } global $startPostion; getActivities($startPostion, $startPostion + DEFAULT_SHOW, $resultsArr, $conn); }
function showActivities($startPos, $uCity, $conn) { global $maxActivityID; //这里要加上这句.不然 loadMoreActivities.php 中会报错 //说 maxActivityID 未定义 $maxActivityID = getMaxActivityID($conn); $resultsArr = array(); if (showUserActivities($uCity)) { $userCitySql = "SELECT * FROM \n\t\t\t\t\t\t\tjobs_activity\n\t\t\t\t\t\t\tWHERE id<={$maxActivityID}\n\t\t\t\t\t\t\tAND city='{$uCity}'\n\t\t\t\t\t\t\tAND flag=0\n\t\t\t\t\t\t\tORDER BY begin_date ASC;"; $userCityActivitiesResults = $conn->query($userCitySql); if ($userCityActivitiesResults->num_rows > 0) { while ($row = $userCityActivitiesResults->fetch_assoc()) { array_push($resultsArr, $row); } } } $sql = "SELECT * FROM \n\t\t\t\tjobs_activity\n\t\t\t\tWHERE id<={$maxActivityID}\n\t\t\t\tAND city!='{$uCity}'\n\t\t\t\tAND flag=0\n\t\t\t\tORDER BY city_flag ASC,\n\t\t\t\tbegin_date ASC;"; $results = $conn->query($sql); if ($results->num_rows > 0) { while ($row = $results->fetch_assoc()) { array_push($resultsArr, $row); } } global $startPos; saveTotalActivitiesCount($startPos, $resultsArr); showActivitiesByPostion($startPos, $startPos + DEFAULT_SHOW, $resultsArr, $conn); }