I can not understand why the $colvo_prav variable $colvo_prav not increase by 1, but displays a bunch of numbers? That is, it is necessary that for every true in the if construct, the $colvo_prav variable is incremented by one. And if if false , then, accordingly, no

 for($i = 1; $i <= 25; $i++) { $cookie_t = $_COOKIE["otveti".$i]; $DB->query = "SELECT correct_answer FROM test3 WHERE id=".$i; $correct_answer = $DB->read('correct_answer'); if($cookie_t != '') { $DB->query = "SELECT answer".$cookie_t." as otv FROM test3 WHERE id=".$i; $vash_otv = $DB->read('otv'); } $colvo_prav = 0; if($correct_answer == $vash_otv){ $colvo_prav++; $verno = "Правильно!"; }else $verno = "Неправильно. Правильный ответ:".$correct_answer; $DB->query = "SELECT question FROM test3 WHERE id=".$i; $question = $DB->read('question'); $otveti_na_voprosy = "Вопрос №".$i.": ".$question."\nВаш ответ:".$vash_otv." ".$verno."\n\n"; echo $colvo_prav; 

Closed due to the fact that it was off topic by Nicolas Chabanovsky Apr 7 '16 at 14:06 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Nicolas Chabanovsky
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    And you show the full code and what ultimately displays. - Alexey Shimansky
  • one
    The answer is simple. you counter constantly reset. $colvo_prav = 0 must be before the cycle begins - Alexey Shimansky
  • one
    before the beginning of the CYCLE , not the terms)) ... before for (... - Alexey Shimansky
  • one
    Well, write echo $colvo_prav already after the cycle and that's it ..... and this is how (echo) is now called up every iteration inside the cycle ... that's why cadabra adabra is Alexei Shimansky
  • one
    Sobssn, when I told you $colvo_prav = 0 должен находится до начала цикла did you really leave $colvo_prav also in the cycle? - Alexey Shimansky

0