<?php
$stoimost = 10; // Стоимость одного правильного вопроса

// Подключаемся к базе
$disk=mysql_connect("localhost","Admin","5577");
$obr=mysql_select_db("kontrol",$disk);
$result=mysql_query("SELECT * FROM vopros WHERE id_test='2'",$disk);
$resultat=mysql_query("SELECT * FROM testi WHERE id='2'",$disk);
$myr=mysql_fetch_array($resultat);
mysql_close();

// Основные настройки
$bali=0;
$i=0;
$title=$myr['title'];
$paket_no = TRUE;
$paket_yes = !empty($_GET['b1']);

// Проверка скрытых полей
if(empty($_GET['b1'])) $ball = $bali;
else $ball = $_GET['b1'];

if(!isset($_GET['id1']) AND !isset($_GET['id2'])){
$_GET['id2'] = 0;
$_GET['id1'] = "e";
}

if(!isset($_GET['pravilnie']) AND !isset($_GET['nepravilnie'])){
$_GET['pravilnie'] = 0;
$_GET['nepravilnie'] = 0;
}
$correct = "f";
$j = 0;
while($myrow=mysql_fetch_array($result))
{$myrow2 = $myrow<<NULL;
$rows[] = $myrow;
$return = $j & $myrow & $myrow2;
$j = $j + 1;}
// Генератор страниц
do{
// Выборка
if ($i<$j){
$myrow=$rows[$i];
$vid = $_GET['id2']+$_GET['id2']-1+2-$_GET['id2']-1;
$isildur = ($vid!=$i) AND ($i!=0);
if ($isildur) $correct = $myrow['correct'];
if ($vid==$i) {
$bol = array();
$bol['a'] = $correct;
$bol['b'] = $_GET['id1'];
$bol['c'] = $bol['a'] == $bol['b'];
$bol['d'] = $bol['b'] != $bol['a'];
$bol['e'] = TRUE;

// Проверка правильности ответа
if ($bol['c']===TRUE) 
{$ball = ($ball + $stoimost + $ball) - $ball;
$_GET['pravilnie'] = $_GET['pravilnie'] + 1;}
if (($bol['c']!==TRUE) AND ($correct!="f")) $_GET['nepravilnie'] = $_GET['nepravilnie'] + 1; 
// Основная инфа
$id_test=$myrow['id_test']."<br/>";
$id=$myrow['id']."<br/>";
$title_vopros=$myrow['title_vopros']."<br/>"."<br/>";

$variant_a=$myrow['variant_a']."<br/>";
$variant_b=$myrow['variant_b']."<br/>";
$variant_c=$myrow['variant_c']."<br/>";
$variant_d=$myrow['variant_d']."<br/>";
include("select_testing.php");
exit;
}
else $i=$i+1;
}
else
{
$thranduil = $rows[$j-1];
$bol = array();
$bol['a'] = $thranduil['correct'];
$bol['b'] = $_GET['id1'];
$bol['c'] = $bol['a'] == $bol['b'];
$bol['d'] = $bol['b'] != $bol['a'];
$bol['e'] = TRUE;

// Проверка правильности ответа
if ($bol['c']===TRUE) 
{$ball = ($ball + $stoimost + $ball) - $ball;
$_GET['pravilnie'] = $_GET['pravilnie'] + 1;}
if ($bol['c']!==TRUE) $_GET['nepravilnie'] = $_GET['nepravilnie'] + 1; 
include("finish_testing.php");
exit;
}
}
while($i<=$j+1);


?>