forked from Fecsio/WeBotanic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualNotizie.php
56 lines (40 loc) · 1.59 KB
/
visualNotizie.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
<?php
session_start();
# se non sei loggato, errore
if( !isset($_SESSION['logged']) or $_SESSION['logged']==0)
header("Location: errore.html");
else
{
$sql = "SELECT Id, Titolo, DataPub FROM Notizie";
require "php/connessione.php";
$output = $connessione->query($sql);
$page = file_get_contents("templates/admin/visualNotizie.txt");
if(!$output) {
$stampa = servError() ;
$page = str_replace('contenuto', $stampa, $page);
}
else {
$stampa = "";
if($output->num_rows == 0) {
$stampa .= "<p class=\"content\"> <p> Nessuna notizia trovata </p><p id=\"indietro\"><a href= \"adminPanel.php\">Torna al menu precedente</a></p> </div>";
$page = str_replace('contenuto', $stampa, $page);
}
else {
$table = file_get_contents('templates/admin/tabVisualNotizie.txt');
foreach($output as $campo => $cont) {
$stampa .= "<tr> \n \t";
foreach($cont as $i => $val) {
$stampa .= "<td>".$val."</td> \n \t";
}
$stampa .= "<td class=\"delete\" > \n \t \t
<a href=\"php/cancella.php?id=".$cont['Id']."&tab=Notizie\" class=\"cancella\">Cancella</a> \n \t
</td> \n \t </tr>";
}
$table =str_replace('corpoTabella', $stampa, $table);
$page = str_replace('contenuto', $table, $page);
}
}
echo $page;
$connessione->close();
}
?>