-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreateTanda.php
More file actions
70 lines (51 loc) · 1.72 KB
/
createTanda.php
File metadata and controls
70 lines (51 loc) · 1.72 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php include('./includes/conn.php');
$namePersona = $_POST['namePersona'];
$turnoPersona = $_POST['turnoPersona'];
$intervalo = $_POST['intervalo'];
$nameTanda = $_POST['nameTanda'];
$numRep = $_POST['numRep'];
$numPeople = $_POST['numPeople'];
$cantidad = $_POST['cantidad'];
$turno = $_POST['turno'];
$today = date("Y-m-d"); //getdate converted day
$id_user = 1;
$return = 0;
$mysqli = con_start();
$smtp = $mysqli->prepare("INSERT INTO Tanda(id_user, turno, name, intervalo_dias, num_personas, num_repeticiones, cantidad, fecha_inicial) VALUES (?,?,?,?,?,?,?,?) ");
$smtp->bind_param("iisiiiis", $id_user, $turnoPersona, $nameTanda, $intervalo, $numPeople, $numRep, $cantidad, $today);
$smtp->execute();
if (!$smtp->error) {
$return += 0;
}
else {
$return += 1;
}
$smtp->close();
$id_tanda = 1;
// Id de tanda que se acaba de insertar
$mysqli = con_start();
$smtp = $mysqli->prepare("SELECT id_tanda FROM Tanda ORDER BY id_tanda DESC LIMIT 1");
$smtp->execute();
$smtp->store_result();
$smtp->bind_result($id_tand);
while ($smtp->fetch()) {
$id_tanda = $id_tand;
}
$smtp->free_result();
$smtp->close();
foreach( $namePersona as $key => $value ) {
$mysqli = con_start();
$smtp = $mysqli->prepare("INSERT INTO UsuariosTanda(id_tanda, nombre, turno) VALUES (?,?,?) ");
$turnoPersona = $turno[$key];
$smtp->bind_param("isi", $id_tanda,$value, $turnoPersona);
$smtp->execute();
if (!$smtp->error) {
$return += 0;
}
else {
$return += 1;
}
$smtp->close();
}
echo $return;
?>