-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper_survey.php
40 lines (34 loc) · 1.18 KB
/
helper_survey.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
<?php
// default values for Xampp when accessing your MySQL database:
function selectAllByIdQuery($varname, $dbSelectName, $dbid, $id, $flag) {
$connection = credentialsFunction();
$dbname = 'skeleton';
// connect to our database:
mysqli_select_db($connection, $dbname);
// bring all the surveys linked to the user:
if ($flag){
$query = "SELECT $varname FROM $dbSelectName WHERE $dbid = '$id'";
}
else {
$query = "SELECT $varname FROM $dbSelectName WHERE $dbid != '$id'";
}
// this query can return data ($result is an identifier):
$results = mysqli_query($connection, $query);
return $results;
}
function credentialsFunction() {
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$connection = mysqli_connect($dbhost, $dbuser, $dbpass);
// exit the script with a useful message if there was an error:
if (!$connection) {
die("Connection failed: " . $mysqli_connect_error);
}
else {
return $connection;
}
}
function TopConstuctGoogleAPI() {
}
?>