<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

	include("connect.php");
?>
<html>
 <head>
  <title>DB Status</title>
 </head>
 <body>
<br>
 Which app users get directed to in Crowdcrafting
 <br>
	<table border = 1>
	<tr>
		<td>App #</td>
		<td>Count</td>
	</tr>
<?php
	$query = "SELECT appnum, count(appnum) FROM userinfo GROUP BY appnum ORDER BY appnum";
	$stmt = $mysqli->prepare($query);
	$stmt->execute();
	$stmt->bind_result($num, $count);

	while ($stmt->fetch()) {
		echo "<tr>";
		echo "<td>$num</td>";
		echo "<td>$count</td>";
		echo "</tr>";
	}

	echo "</table>";
	$stmt->close();

	$query2 = "SELECT * FROM userinfo";
	$stmt2 = $mysqli->prepare($query2);
	$stmt2->execute();
	$stmt2->bind_result($userid, $appnum, $test1, $response1, $test2, $response2, $passtest);
?>

<br>
 db details below:
 <br>
	<table border = 1>
	<tr>
		<td>User Id</td>
		<td>App #</td>
		<td>Test 1</td>
		<td>Response 1</td>
		<td>Test 2</td>
		<td>Response 2</td>
		<td>Pass Test?</td>
	</tr>

<?php
	while ($stmt2->fetch()) {
		echo "<tr>";
		echo "<td>$userid</td>";
		echo "<td>$appnum</td>";
		echo "<td>$test1</td>";
		echo "<td>$response1</td>";
		echo "<td>$test2</td>";
		echo "<td>$response2</td>";
		echo "<td>$passtest</td>";
		echo "</tr>";
	}

	echo "</table>";
	$stmt2->close();
	$mysqli->close();
?>
 </body>
</html>
