function is_new_news(news_def &$news) { $var = find_news($news); if ($var == false) { return true; } return false; }
<!DOCTYPE html> <?php include_once "database.php"; $id = $_GET['id']; $news = find_news($id); ?> <html> <head> <title>News</title> <link href="assets/style.css" rel="stylesheet"> <link href="assets/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="box-event"> <?php foreach ($news as $n) { ?> <div> <?php echo "<h2>" . $n['title'] . "</h2>"; ?> <div><?php echo "<h4> (" . $n['newsType'] . ")</h4>"; ?> </div> <hr/> </div> <p><?php echo $n['info']; ?>
return $ile; } $na_stronie = 5; $query = "select count(*) from news"; $wynik = XDb::xSql($query); $ile = XDb::xFetchArray($wynik); $ile = $ile[0]; $tpl->assign('ile', $ile); if ($ile <= $na_stronie) { find_news(0, $na_stronie); } else { if (!isset($_GET['page'])) { find_news(0, $na_stronie); $next_page = '2'; } elseif (isset($_GET['page']) && !empty($_GET['page']) && preg_match("/^\\d+\$/", $_GET['page'])) { $ile_wynikow = find_news(($_GET['page'] - 1) * $na_stronie, $na_stronie); if ($ile_wynikow == 0) { header('Location: ./news.php?page=1'); exit; } else { if (($_GET['page'] - 1) * $na_stronie + $na_stronie <= $ile) { $next_page = $_GET['page'] + 1; } $prev_page = $_GET['page'] - 1; } } } $tpl->assign('max', ceil($ile / $na_stronie)); $tpl->assign('next_page', $next_page); $tpl->assign('prev_page', $prev_page); $tpl->display('tpl/news.tpl');
<?php if ($ile <= $na_stronie) { find_news(0, $na_stronie); } else { if (!isset($_GET['page'])) { find_news(0, $na_stronie); $next_page = '2'; } elseif (isset($_GET['page']) && !empty($_GET['page']) && preg_match("/^\\d+\$/", $_GET['page'])) { $start = ($_GET['page'] - 1) * $na_stronie; $limit = $na_stronie; //print $start." ".$limit; find_news($start, $limit); //print $ile."f"; if (empty($znalezione)) { header('Location: ' . $url . '&page=1'); exit; } else { if (($_GET['page'] - 1) * $na_stronie + $na_stronie < $ile) { $next_page = $_GET['page'] + 1; } $prev_page = $_GET['page'] - 1; } } }