-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionsDB.php
More file actions
73 lines (62 loc) · 2.41 KB
/
functionsDB.php
File metadata and controls
73 lines (62 loc) · 2.41 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
71
72
73
<?php
//---------------- naujienu/straipsniu papildymas --------------------
function papildyti()
{ ?><div class="d-flex justify-content-center">
<form method="POST" enctype="multipart/form-data">
<p>Pavadinimas
<br><input type="text" size="50" name="Pav" maxlength="255">
</p>
<p>Tekstas
<br><textarea name="T" cols="50" rows="5" maxlength="65535"></textarea>
</p>Nuotrauka<br>
<input type="file" name="failas" id="">
<input type="submit" value="Įrašyti..." name="Irasyti"></p>
</form></div>
<?php
}
function trinti($id)
{
$conn = mysqli_connect('localhost', 'root', '', 'italija');
$conn -> set_charset("utf8");
$del="delete from straipsniai where ID=$id";
$sql = "select * from straipsniai where ID=$id";
$rez = $conn->query($sql);
$eil = $rez->fetch_assoc();
$filename ='C:\wamp64\www\php\ItalijaProj\img\str/'.$eil['nuotrauka'];
echo $filename;
unlink($filename);
$conn->query($del);
echo RE.FRE.SH;
}
//----------------- straipsniu atvaizdavimas -------------------
function lentele()
{
$conn = mysqli_connect('localhost', 'root', '', 'italija') or die("Negaliu prisijungti prie DB");
$conn -> set_charset("utf8");
$query = "select * from straipsniai";
$rez = mysqli_query($conn, $query) or die("<p>Sistemos klaida...<br>Pamėginkite vėliau</p>");
$kiek = mysqli_num_rows($rez);
echo '<form method="post" class="center"><input type="submit" value="Naujas keliones straipsnis" name="Papildyti"></form>';
echo '<table class="table">';
echo '<thead class="thead-dark"><tr><th scope="col">ID</th><th scope="col">tipas</th><th scope="col">Pavadinimas</th><th scope="col">Tekstas</th><th scope="col">Laikas</th><th scope="col">Veiksmai</th></tr></thead>';
for ($i = 0; $i < $kiek; $i++) {
$e = mysqli_fetch_assoc($rez);
if ($e['tipas'] == 'kel') {
$b = 'Kelioninis';
} else {
$b = 'Restoranas';
}
echo '<tr><td valign="top">' . $e['ID'] . '</td>';
echo '<td valign="top">' . $b . '</td>';
echo '<td valign="top">' . $e['pavadinimas'] . '</td>';
echo '<td valign="top">' . substr($e['tekstas'], 0, 600) . '...</td>';
echo '<td valign="top">' . $e['data'] . '</td>';
echo '<td valign="top">';
if($b=='Kelioninis'){
echo
<form method="post"><input type="hidden" name="Tr" value="' . $e['ID'] . '"><input type="image" src="img/trash.png" title="Trinti"></form></td>';
}
}
echo '</tr></table>';
}
?>