Jump to content

Set a limit for showing data?


knz

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/150680-set-a-limit-for-showing-data/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.