-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
53 lines (49 loc) · 2.32 KB
/
index.php
File metadata and controls
53 lines (49 loc) · 2.32 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
<?php
include 'config.php';
session_start();
$stmt = $conn->prepare("SELECT * FROM news ORDER BY id DESC");
$stmt->execute();
$newsCollection = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<?php include 'includes/header.php'; ?>
<div class="container">
<h3 class="text-center">Главная</h3>
<div class="row mt-4">
<?php foreach ($newsCollection as $news): ?>
<div class="col-md-4 mb-4">
<div class="card">
<img src="assets/images/News.gif" class="card-img-top" alt="<?php echo htmlspecialchars($news['name']); ?>">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($news['name']); ?></h5>
<p class="card-text"><?php echo htmlspecialchars($news['description']); ?></p>
<form method="post" action="single/news">
<input type="hidden" name='news_id' value="<?php echo htmlspecialchars($news['id']); ?>">
<button type="submit" class="btn btn-primary">
Подробнее
</button>
</form>
</div>
</div>
</div>
<div class="modal fade" id="news<?php echo $news['id']; ?>Modal" tabindex="-1" role="dialog" aria-labelledby="news<?php echo $news['id']; ?>ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="news<?php echo $news['id']; ?>ModalLabel"><?php echo $news['name']; ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p><?php echo $news['full_description']; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php include 'includes/footer.php'; ?>