insertAndMakeListUser.php update
continuous-integration/drone/push Build is passing Details

remotes/origin/mvc-implementation
Dorian HODIN 2 years ago
parent c906dd0ba3
commit e2c4a35dc4

@ -37,9 +37,6 @@ function insertUserAndReturnList(): array|int
);"; );";
mysqli_query($res, $query); mysqli_query($res, $query);
$query = "UPDATE gps SET latitude='0', longitude='0', idMusic='0' WHERE id='0'"; //Delete the actual line and replace this line with the next lines
return (mysqli_query($res, $query));
if (!empty($_POST)) { //Check if the method POST return something if (!empty($_POST)) { //Check if the method POST return something
$id = $_POST['id']; //Get the result of POST method $id = $_POST['id']; //Get the result of POST method
@ -55,21 +52,16 @@ function insertUserAndReturnList(): array|int
$results = mysqli_query($connect, $query); $results = mysqli_query($connect, $query);
*/ */
$query = "SELECT id FROM gps WHERE id = '$id' "; $query = "UPDATE gps SET latitude='$latitude', longitude='$longitude', idMusic='$idMusic' WHERE id='$id'"; //Delete the actual line and replace this line with the next lines
$results = mysqli_query($res, $query); //Execute the SQL command $results = mysqli_query($res, $query); //Execute the SQL command
if (empty($results)){ if ($results==0){
$query = "INSERT INTO gps(id,latitude,longitude,idMusic,dateLog) VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user $query = "INSERT INTO gps(id,latitude,longitude,idMusic,dateLog) VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user
mysqli_query($res, $query);
}else{
$query = "UPDATE gps SET latitude='$latitude', longitude='$longitude', idMusic='$idMusic' WHERE id='$id'"; //Delete the actual line and replace this line with the next lines
} }
mysqli_query($res, $query);
$query = "SELECT * FROM gps WHERE id != '$id'"; //Browse all the database $query = "SELECT * FROM gps WHERE id != '$id'"; //Browse all the database
$results = mysqli_query($res, $query); //Execute the SQL command $results = mysqli_query($res, $query); //Execute the SQL command
$listUser = []; //Set the listUser to an empty list $listUser = []; //Set the listUser to an empty list

Loading…
Cancel
Save