179ba302
msekar
Connect to databa...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<?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);
?>
|