knz Posted March 23, 2009 Share Posted March 23, 2009 I have a trivia highscore script. The script contain among other a value for QuestionsCorrect, QuestionsAnswered and Ratio (QuestionsCorrect/QuestionsAnswered * 100 ). The list is sorted by the ratio! To avoid that a user can top the list just by answering one question and get it right (= 100%) As it is now every person who takes the quiz ends up in the highscore-list. I want it to have a limit for example: QuestionsAnswered > 30. I want it to store the data for all answers just not print in until QuestionsAnswered > 30. I've figured I need some kind of simple if statement, but I dont know how it should look like and have no idea where to put it in my code? Link to the code: http://pastebin.com/m13b470d7 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/150680-set-a-limit-for-showing-data/ Share on other sites More sharing options...
kickstart Posted March 23, 2009 Share Posted March 23, 2009 Hi Not sure if I am missing something but couldn't you just do:- if (!$boolError) { $sql = "SELECT (`QuestionsCorrect` / `QuestionsAnswered` * 100) AS `ratio`, HighScoreNumber FROM highscores WHERE QuestionsAnswered > 30 ORDER BY TableName DESC, ratio DESC, QuestionsCorrect DESC, QuestionsAnswered DESC "; $strTempDBInfo1 = DBTYPE."_query"; $result1 = $strTempDBInfo1($sql); if (!$result1) { $strTempDBInfo1 = DBTYPE."_error"; $strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo1($conn); $boolError = true; } } It would still be stored in your DB. Or do you want to bring them back even if if they have answered less than 30 questions but just not display them? All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150680-set-a-limit-for-showing-data/#findComment-791626 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.