Merge remote-tracking branch 'origin/SQL_Script' into SQL_Script

remotes/origin/mvc-implementation
Lucas DELANIER 2 years ago
commit afc7561f33

@ -37,7 +37,6 @@ function insertUserAndReturnList(): array|int
);"; );";
mysqli_query($res, $query); 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
@ -56,7 +55,7 @@ function insertUserAndReturnList(): array|int
$query = "SELECT id FROM gps WHERE id = '$id' "; $query = "SELECT id FROM gps WHERE id = '$id' ";
$results = mysqli_query($res, $query); //Execute the SQL command $results = mysqli_query($res, $query); //Execute the SQL command
if (empty($results)){ if (empty($results->fetch_row()[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
@ -87,10 +86,7 @@ function insertUserAndReturnList(): array|int
} }
} }
if (!empty($listUser)){ return $listUser; //Return an array
return 2;
}
return 3; //Return an array
} else { //If the method POST return nothing } else { //If the method POST return nothing

@ -0,0 +1,7 @@
<?php
include "config.php";
$res = connection();
$query = "DELETE FROM gps WHERE id='0'";
mysqli_query($res, $query);
Loading…
Cancel
Save