-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincludes.php
70 lines (69 loc) · 2.28 KB
/
includes.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
* Application Creator
* Created By Chris Cerne
* Copyright (C) 2014 Chris Cerne All Rights Reserved
*
* Important: Do not edit this configuration file, unless you know what you are doing.
*/
$config = include dirname(__FILE__) . '/config.php';
$con = mysqli_connect($config['mysql_server'], $config['mysql_username'], $config['mysql_password'], $config['mysql_database']);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit;
}
function getQuestionNum() {
//Get Statistics
global $config;
global $con;
return mysqli_num_rows(mysqli_query($con, "SELECT * FROM " . $config['mysql_table_questions'] . " ORDER BY id ASC"));
}
function getHeaders() {
//Get all the headers
global $config;
global $con;
$result = mysqli_query($con, "SELECT category FROM " . $config['mysql_table_questions'] . " ORDER BY id ASC");
$arr = array();
while($row = mysqli_fetch_array($result)){
$arr[] = $row['category'];
}
return array_unique($arr);
}
function getQuestions($heading) {
//Get questions pertaining to a heading
global $config;
global $con;
$result = mysqli_query($con, "SELECT question FROM " . $config['mysql_table_questions'] . " WHERE category = '" . mysqli_real_escape_string($con, $heading) . "' ORDER BY id ASC");
$arr = array();
while($row = mysqli_fetch_array($result)){
$arr[] = $row['question'];
}
return $arr;
}
function getAllQuestions() {
global $config;
global $con;
$result = mysqli_query($con, "SELECT question FROM " . $config['mysql_table_questions'] . " ORDER BY id ASC");
$arr = array();
while($row = mysqli_fetch_array($result)){
$arr[] = $row['question'];
}
return $arr;
}
function getCat($question) {
//Get questions pertaining to a heading
global $config;
global $con;
$result = mysqli_query($con, "SELECT type FROM " . $config['mysql_table_questions'] . " WHERE question = '" . mysqli_real_escape_string($con, $question) . "' ORDER BY id ASC");
$arr = array();
while($row = mysqli_fetch_array($result)){
$arr[] = $row['type'];
}
return $arr;
}
function getRow($cat) {
global $config;
global $con;
return mysqli_fetch_array($con, mysqli_query($con, "SELECT * FROM " . $config['mysql_table'] . " WHERE category = '" . $cat . "' ORDER BY id ASC"));
}
?>