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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.