size() > 2 ) $topicid = $pathVars->fetchByIndex(2); else $topicid = $pathVars->fetchByIndex(1); loadScoreHeader(); loadMyscore($session,$db,20); loadTopscore($db,$topicid,20,10); function loadScoreHeader() { $template = new HTML_Template_ITX(D_TEMPLATES); $template->loadTemplatefile(T_TOPSCORE_HEADER, true, true); $template->setVariable('S_TITLE', 'Top Score'); $template->setCurrentBlock(); $template->parseCurrentBlock(); echo $template->get(); } //move loadMyscore module to winestore.inc function loadTopscore($db,$topicid,$size,$daybefore) { $score = array(); $template = new HTML_Template_ITX(D_TEMPLATES); $template->loadTemplatefile(T_TOPSCORE, true, true); $template->setVariable('S_TITLE', 'Top Score'); $template->setVariable('S_TOPIC',getTopicname($db,$topicid)) ; $template->setVariable('S_CLN1',"Ranking"); $template->setVariable('S_CLN2',"Score"); $template->setVariable('S_CLN3',"School"); $template->setVariable('S_CLN4',"Date/Time"); $sql="SELECT * FROM ".SCORE_TABLE. " WHERE ".SCORE_TABLE_TOPIC_ID." = ".$topicid. " AND ".SCORE_TABLE_SCORETIME. " > (" .SCORE_TABLE_SCORETIME." - ".C_DAYSECOND. " * " . $daybefore . " ) ". " ORDER BY ".SCORE_TABLE_SCORE." DESC LIMIT ".$size; if (DEBUG) { println ($sql);} // Fetch the result object $result=$db->query($sql); $qcnt=1; // Iterate through the results while ($row = $result->fetch()) { $score[$qcnt][1] = $qcnt; $score[$qcnt][2] = 100*$row[SCORE_TABLE_SCORE].'%'; //scoee $score[$qcnt][3] = getSchool($db,$row[SCORE_TABLE_USER_ID]); //school //$score[$qcnt][4] = date('F j,Y,g:i a',$row['scoretime']); $score[$qcnt][4] = date('F j,Y H:i:s',$row[SCORE_TABLE_SCORETIME]); $qcnt = $qcnt + 1; } // End of while loop $template->setCurrentBlock(); for ($qcnt=1;$qcnt<$size+1;$qcnt++) { $template->setVariable('S_S'.$qcnt.'1', $score[$qcnt][1]); $template->setVariable('S_S'.$qcnt.'2', $score[$qcnt][2]); $template->setVariable('S_S'.$qcnt.'3', $score[$qcnt][3]); $template->setVariable('S_S'.$qcnt.'4', $score[$qcnt][4]); } $template->parseCurrentBlock(); echo $template->get(); } function getSchool($db,$usrid) { $sql="SELECT ".SIGNUP_TABLE_SCHOOL."," .SIGNUP_TABLE_LNAME."," .SIGNUP_TABLE_FNAME . " FROM " .SIGNUP_TABLE. " WHERE " .SIGNUP_TABLE_LOGIN. " = ". "'".$usrid."'"; // Fetch the result object $result=$db->query($sql); $row = $result->fetch(); $schoolId = $row[SIGNUP_TABLE_SCHOOL]; $studetInit = $row[SIGNUP_TABLE_LNAME][0].'.'.$row[SIGNUP_TABLE_FNAME][0]; $sql="SELECT " .SCHOOL_TABLE_SNAME. " FROM " . SCHOOL_TABLE . " WHERE " .SCHOOL_TABLE_SID. " = " ."'".$schoolId."'"; $result=$db->query($sql); $row = $result->fetch(); return $row[SCHOOL_TABLE_SNAME].'('.$studentInit.')'; } ?>