androidconn.php
768 Bytes
<?php
$conn = mysqli_connect('localhost', 'mysql_user', 'mysql_passwd', 'IoT');
$newTraining= $_POST['newTraining'];
$name = $_POST['name'];
$lapTime = $_POST['lapTime'];
$trainingDate = $_POST['trainingDate'];
$max = mysqli_query($conn,"SELECT MAX(trainingId) FROM training");
if($newTraining==1){
$max+=1;
$lastLap=0;
}
else $lastLap = mysqli_query($conn,"SELECT MAX(lapId) FROM lap WHERE trainingId='$max'");
$iduser = mysqli_query($conn, "SELECT id FROM user WHERE name='$name'");
$result = mysqli_query($conn, "INSERT INTO training (trainingId, trainingDate, userId) VALUES ('$max', '$trainingDate', '$iduser')");
$result = mysqli_query($conn, "INSERT INTO lap (lapId, lapTime, trainingId) VALUES ('$lastLap', '$lapTime', '$max')");
mysqli_close($conn);
?>