-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroupwork.php
More file actions
52 lines (50 loc) · 1.23 KB
/
groupwork.php
File metadata and controls
52 lines (50 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
session_start();
include('checkuser.php');
require_once('connect.php');
require 'libs/Smarty.class.php';
$db = db_connect();
$stmt = $db->stmt_init();
$problems = array();
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$limit = ($page-1) * 2;
$limit = $limit . ',2';
$sql = "SELECT question,answer,id FROM problem LIMIT " . $limit;
if ($stmt->prepare($sql))
{
$stmt->execute();
$stmt->bind_result($question,$answer,$id);
while($stmt->fetch())
{
array_push($problems,array('question'=>$question,'answer'=>$answer,'key'=>$id));
}
if ($stmt->prepare("SELECT COUNT(question) FROM problem")) {
$stmt->bind_result($count);
$stmt->execute();
$stmt->fetch();
}
$stmt->close();
}
$db->close();
if ($page != 1) {
$prev = "groupwork.php?page=" . ($page - 1);
} else {
$prev = "#";
}
$next = "groupwork.php?page=" . ($page + 1);
$smarty = new Smarty;
//$smarty->force_compile = true;
//$smarty->debugging = true;
//$smarty->caching = true;
//$smarty->cache_lifetime = 120;
$smarty->assign('problems',$problems);
$smarty->assign('title','Group Work');
$smarty->assign('prev',$prev);
$smarty->assign('page',$page);
$smarty->assign('next',$next);
$smarty->display('groupwork.tpl');
?>