-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdonations.php
More file actions
84 lines (65 loc) · 2.33 KB
/
donations.php
File metadata and controls
84 lines (65 loc) · 2.33 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include ('server.php');
class donations {
//call with only first 6 parameters, isNew is defaulted to true
public function sqlInsert($donor, $contact, $email, $phone, $description, $foodType, $distcenter, $isNew = 1){
global $servername;
global $username;
global $password;
global $dbname;
$connection = new mysqli($servername, $username, $password, $dbname);
if($connection === null){
echo "Error connecting to database";
}
$theInsert = $connection->prepare("INSERT INTO donations SET DONOR=?, CONTACT=?, EMAIL=?, PHONE=?, DESCRIPTION=?, FOODTYPE=?, DISTID=?, ISNEW=?");
$theInsert->bind_param("sssssisi", $donor, $contact, $email, $phone, $description, $foodType, $distcenter, $isNew);
$theInsert->execute();
server::emailClients();
}
//function runs through all the contents of the database and converts their ISNEW value to 0
public function makeOld(){
global $servername;
global $username;
global $password;
global $dbname;
$connection = new mysqli($servername, $username, $password, $dbname);
if($connection === null){
echo "Error connecting to database";
}
$theUpdate = "UPDATE donations SET ISNEW=0 WHERE 1 > 0";
$connection->query($theUpdate);
}
//return all entries in the table matching the ISNEW value specified in the input parameter (0 or 1)
public function rowInfo($newOrOld){
global $servername;
global $username;
global $password;
global $dbname;
$connection = new mysqli($servername, $username, $password, $dbname);
if($connection === null){
echo "Error connecting to database";
}
$theUpdate = "SELECT * FROM donations WHERE ISNEW=$newOrOld";
$allRows = array();
if($row = $connection->query($theUpdate)){
while($distinctRow = $row->fetch_array(MYSQL_NUM)){
$allRows[] = $distinctRow;
}
}
return $allRows;
}
//function to wipe the existing contents of the database
public function clearIt(){
global $servername;
global $username;
global $password;
global $dbname;
$connection = new mysqli($servername, $username, $password, $dbname);
if($connection === null){
echo "Error connecting to database";
}
$theUpdate = "DELETE FROM donations WHERE 1";
$connection->query($theUpdate);
}
}
?>