You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

122 lines
3.6 KiB

<?php
$extraQ="";
if($getQ[2]=="find"){
$extraQ = "WHERE title LIKE '%".$getQ[3]."%' OR text LIKE '%".$getQ[3]."%' ";
}
$q = mysqli_query($conn, "SELECT COUNT(id) FROM news $extraQ");
$r = mysqli_fetch_array($q);
$totNews = $r[0];
$itemsPage = 5;
$currentPage = $getQ[1];
$totPages = $totNews/$itemsPage;
$pageStart = $currentPage * $itemsPage;
if($getQ[2] && $getQ[2]!="find"){
$q = mysqli_query($conn, "SELECT * FROM news WHERE id=".$getQ[2]);
$r = mysqli_fetch_array($q);
?>
<div class="row news">
<div class="col-12">
<div class="section-title">Notizie dall'Ordine</div>
</div>
<div class="col-12 my-2">
<div class="section-text">
<p class="item py-3 h6"><span class="date"><?php echo conv_date($r['date']);?></span> - <?php echo $r['title'];?></p>
<p class="p-2"><?php echo $r['text'];?></p>
<?php
if($r['append']){
echo "<div class=\"append\">";
echo "<div class=\"item pt-4 font-bold\">Allegati:</div>";
$qa = mysqli_query($conn, "SELECT * FROM files WHERE id IN(".$r['append'].")");
while($ra = mysqli_fetch_array($qa)){
echo "<div class=\"item\"><a href=\"$BASE_URL".$ra['path']."/".$ra['filename']."\" target=\"_blank\">".$ra['title']."";
echo "<div class=\"size\">".$ra['size']."</div>";
echo "</a></div>";
}
echo "</div>";
}
?>
</div>
</div>
<div class="col-12 p-4">
<?php
@include 'social.php';
@include 'fb_comments.php';
?>
</div>
<div class="col-6 p-3">
<a onClick="javascript:history.back()">
<button><i class="fa fa-angle-left"></i> Torna indietro</button>
</a>
</div>
<div class="col-6 p-3 text-right">
<a href="<?php echo $BASE_URL."/news";?>">
<button>Vai a tutte le news <i class="fa fa-angle-right"></i></button>
</a>
</div>
</div>
<?php
}else{
?>
<div class="row news">
<div class="col-12">
<div class="section-title">Notizie dall'Ordine</div>
</div>
<div class="col-12 col-sm-6 mx-auto">
<form id="news-find">
<div class="row py-2 font-14">
<!-- <div class="col-6 d-none d-sm-block"></div> -->
<div class="col"><input type="text" class="q" value="<?= $getQ[3];?>"></div>
<div class="col-auto"><button type="submit">Cerca <i class="fa fa-search"></i></button></div>
<div class="col-12 px-3 font-12"><?php if($getQ[2]=="find"){echo "Ricerca terminata, ".$totNews." notizie corrispondono ai criteri di ricerca.";}?></div>
</div>
</form>
</div>
<div class="col-12 my-2">
<?php
$q = mysqli_query($conn, "SELECT * FROM news $extraQ ORDER BY date DESC LIMIT $pageStart,$itemsPage");
while($r = mysqli_fetch_array($q)){
echo "<p class=\"item\"><a href=\"$BASE_URL/news/0/".$r['id']."/".conv_url($r['title'])."\"><span class=\"date\">".conv_date($r['date'])." </span> - ".$r['title']."</a></p>";
}
?>
</div>
<div class="col-12 my-2 pages">
<?php
$findAppend = ($getQ[2]=="find") ? $getQ[2]."/".$getQ[3] : "";
for($i=0;$i<$totPages;$i++){
echo "<a class=\"font-12 ";
if($i==$currentPage){echo "selected";}
echo "\" href=\"$BASE_URL/news/$i/$findAppend\">".($i+1)."</a>";
}
?>
</div>
</div>
<?php
}
?>