-
Notifications
You must be signed in to change notification settings - Fork 0
/
getGroup.php
75 lines (61 loc) · 2.27 KB
/
getGroup.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
71
72
73
74
75
<?php
//include 'ChromePhp.php';
$servername = "server-ip";
$username = "username";
$password = "password";
$dbname = "database-name";
$mysqli = new mysqli($servername, $username, $password, $dbname);
if ($mysqli->connect_errno)
{
echo "Error: Failed to make a MySQL connection, here is why: \n";
echo "Errno: " . $mysqli->connect_errno . "\n";
echo "Error: " . $mysqli->connect_error . "\n";
exit;
}
if( $_POST["client"] == 'processing' )
{
$venueName = $_POST["name"];
$sql = 'SELECT count FROM venue WHERE name = "'.$venueName.'"';
if (!$result = $mysqli->query($sql))
{
echo "Sorry, the website is experiencing problems.";
}
$count = $result->fetch_assoc()[count];
//echo "Count number: " . $count;
$count++;
$updateSQL = 'UPDATE venue SET count="'.$count.'" WHERE name="'.$venueName.'"';
$procSQL = 'SELECT count FROM venue WHERE name = "'.$venueName.'"';
$procResult = $mysqli->query($procSQL);
$procCount = "Total Amount of Click: " . $procResult->fetch_assoc()[count];
echo $procCount;
if (!$result = $mysqli->query($updateSQL))
{
echo "Sorry, the website is experiencing problems.";
}
} else {
//$test = 'Atak';
//$atak = 'SELECT count FROM venue WHERE name = "Atak"';
$getData = 'SELECT * FROM venue';
if (!$result = $mysqli->query($getData))
{
echo "Sorry, the website is experiencing problems.";
}
if(is_ajax()){
while($count = $result->fetch_assoc()){
//$return["name"] = $count[name];
//$return["count"] = $count[count];
$return[] = $count;
}
echo json_encode($return);
}
// $count = $result->fetch_assoc()[count];
//echo "Other count: ".$count;
//echo "<br /> With words $count";
}
$result->free();
$mysqli->close();
function is_ajax(){
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
?>