/
table.php
77 lines (52 loc) · 1.74 KB
/
table.php
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
71
72
73
74
75
76
77
<?php
require_once("funktsioon.php");
require_once("edit_user.php");
if(isset($_POST["update"])){
updateCar($id, $autonr, $sisenemismass, $lahkumismass);
}
if(isset($_GET["delete"])){
deleteCar($_GET["delete"]);
}
$autodd = getCar();
//var_dump($car_list);
?>
<table border=1 >
<tr>
<th>id</th>
<th>kasutaja id</th>
<th>Autode nr</th>
<th>Sisenemismass</th>
<th>Lahkumismass</th>
<th>X</th>
</tr>
<?php
// count($car_list) - massiivi pikkus
for($i = 0; $i < count($autodd); $i++){
// $i = $i +1; sama mis $i += 1; sama mis $i++;
if(isset($_GET["edit"]) && $autodd[$i]->id == $_GET["edit"]){
echo "<tr>";
echo "<form action='table.php' method='post'>";
echo "<td>".$autodd->id."</td>";
echo "<td>".$autodd->user_id."</td>";
echo "<td><input name='autonr' value='".$autodd->autonr."'></td>";
echo "<td><input name='sisenemismass' value='".$autodd->sisenemismass."'></td>";
echo "<td><input name='lahkumismass' value='".$autodd->lahkumismass."'></td>";
echo "<td><input type='submit' name='update'></td>";
echo "<td><a href='table.php'>cancel</a></td>";
echo "</form>";
echo "</tr>";
}else{
// tavaline rida
echo "<tr>";
echo "<td>".$autodd[$i]->id."</td>";
echo "<td>".$autodd[$i]->user_id."</td>";
echo "<td>".$autodd[$i]->autonr."</td>";
echo "<td>".$autodd[$i]->sisenemismass."</td>";
echo "<td>".$autodd[$i]->lahkumismass."</td>";
echo "<td><a href='?delete=".$autodd[$i]->id."'>X</a></td>";
echo "<td><a href='?edit=".$autodd[$i]->id."'>edit</a></td>";
//echo "</tr>";
}
}
?>
</table>