<?php
include("var.php"); //include config file
$con = mysqli_connect($DBHOST,$DBUSER,$DBPASS,$DBNAME) or die("Some error occurred during connection " . mysqli_error($con));  
mysqli_query($con, "SET CHARACTER SET 'utf8'");
if($_POST)
{
	//sanitize post value
	$group_number = filter_var($_POST["group_no"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
	$tony = $_POST["tony"];
	$globaldata = @mysqli_fetch_array(mysqli_query($con, "select * from `lang` where `id`='$tony' limit 0,1"));
	
	//throw HTTP error if group number is not valid
	if(!is_numeric($group_number)){
		header('HTTP/1.1 500 Invalid number!');
		exit();
	}
	
	//get current starting point of records
	$position = ($group_number * $items_per_group);
	//Limit our results within a specified range. 		
$result2 = mysqli_query($con, "SELECT * FROM quiz where live=1 AND lang='$tony' ORDER BY id DESC LIMIT $position, $items_per_group");
$num = @mysqli_num_rows($result2);
$i = 0;
while($myresult = mysqli_fetch_array($result2))
{
$title = $myresult["title"];
$desc = $myresult["desc"];
$id = $myresult["id"];
$img = $myresult["img"];
   $string = str_replace(' ', '-', base64_decode($title)); // Replaces all spaces with hyphens.
   $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
?>
			<div class="jumbotron" style="margin-top: 10px;">
				<h2><?=base64_decode($title)?></h2>
				<p class="lead">
					<small><?=base64_decode($desc)?></small>
			<? if ($img != "")
			{ ?>
					<div class="hidden-xs hidden-sm"><img src="img/<?=$img?>"></div>
					<div class="visible-xs visible-sm"><img src="img/<?=$img?>" width="70%"></div>
			<?}?>
				</p>
				<p>
<a class="btn btn-lg btn-success" href="id=<?=$id?>"><?=base64_decode($globaldata['startquiz'])?></a>
				</p>
			</div>
<?
$i++;
}

}
?>