-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateFund.php
46 lines (39 loc) · 1.28 KB
/
updateFund.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
<?php
include 'functions.php';
// In this file we will update the values in the database.
if(!empty($_POST["fid"]))
{
$fid = $_POST['fid'];
updateValue("FundName", $_POST["fundName"], $fid);
updateValue("Activity", $_POST["activity"], $fid);
updateValue("Fund", $_POST["fund"], $fid);
updateValue("Function", $_POST["function"], $fid);
updateValue("CostCenter", $_POST["costCenter"], $fid);
updateValue("ProjectCode", $_POST["projectCode"], $fid);
updateValue("Balance", $_POST["balance"], $fid);
updateValue("Users", $_POST["users"], $fid);
updateValue("Active", $_POST["active"], $fid);
// Update the date on the fund, because the balance has been updated.
updateValue("BalanceAsOf", date("m/d/y"), $fid);
}
// Redirect to funds.php
header( 'Location: ./funds.php' ) ;
// Updates a single value.
function updateValue($valueName, $newValue, $valueID)
{
// Prevents writting an empty value to the table.
if(empty($valueName) OR empty($newValue) OR empty($valueID))
return;
$conn = connectTODB();
$sql = "UPDATE ListOfFunds SET ".$valueName."='".$newValue."' WHERE FID=".$valueID;
if ($conn->query($sql) === TRUE)
{
echo $valueName."updated successfully";
}
else
{
echo "Error updating record: " . $conn->error . "<br>";
}
$conn->close();
}
?>