-
Notifications
You must be signed in to change notification settings - Fork 1
/
iupdate.php
36 lines (26 loc) · 1.23 KB
/
iupdate.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
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
include_once ("../config.php");
$json = $_POST["json"];
if (json_decode($json) !=null) { //if the json is valid
$j=json_decode($json);
echo $json;
$stmt=$conn->prepare("select compName from comps where compLetters=?");
$stmt->bind_param("s", $j->compLetters);
$stmt->execute();
$result = $stmt->get_result(); //just getting the current thing to make sure
$stmt->close();
if (mysqli_num_rows($result) == 1) { //if it already exists do an update
$j->lifterClass=intval($j->lifterClass);
if($stmt=$conn->prepare("UPDATE comps SET lifterName=?, currentAttempt=?, total=?, compStatus=?, lifterTeam=?, lifterBW=?, lifterClass=?, lifterCat=?, lifterFlight=?, nextLoad=?, nextName=?, nextLot=?, nextRack=?, lot=?, rack=?, bar=? WHERE compLetters=?")){
$stmt->bind_param("sddisdsssdsisisds", $j->lifterName, $j->currentAttempt, $j->total, $j->compStatus, $j->lifterTeam, $j->lifterBW, $j->lifterClass, $j->lifterCat, $j->lifterFlight, $j->nextLoad, $j->nextName, $j->nextLot, $j->nextRack, $j->lot, $j->rack, $j->bar, $j->compLetters);
$stmt->execute();
$stmt->close();
echo "attempted to execute";
}
}
//all done updating
$conn->close();
} //end of the 'valid json check'
?>