-
Notifications
You must be signed in to change notification settings - Fork 0
/
all-trips.php
58 lines (53 loc) · 1.96 KB
/
all-trips.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
57
58
<!-- Tabs file for all the trips -->
<div class='all-trips-box'>
<?php
$conn = false;
$file='./connection.php';
if(file_exists($file)) {include($file);}
//set variables and check for connection
$content = '';
if (!$conn) {
//If not connected
$content.= "Can not conect with database !!!";
}
else
{
//If connection succes execute sql
$res = $conn->query('SELECT * FROM tripsmodel LIMIT 6');
while($row=$res->fetch()) {
//Get all the records and assign them to variables
$id= htmlentities($row['id']);
$name = htmlentities($row['name']);
$type = htmlentities($row['type']);
$time = htmlentities($row['time']);
$bprice = htmlentities($row['bprice']);
//Put those variables into html code set in variable
$content.= '<div class="trip-box">
<img src="img/trip-card/'.$name.'.jpg">
<div class="trip-info">
<h3> '. $name. '</h3>
<h4> '. $type. ' </h4>
<h4> '. $time. ' days</h4>
<h4> '. $bprice. ' € </h4>
<a href="trip.php?tmid='.$id.'">More</a>
</div>
</div>';
}
}
//Show where statement is true
echo $content;
?>
<!-- JavaScript Code to Show More -->
<script>
$(document).ready(function() {
var tripsCount = 6;
$("button").click(function() {
tripsCount = tripsCount + 6;
$(".all-trips-box").load("load-trips.php", {
tripsNewCount: tripsCount
});
});
});
</script>
</div>
<button class="load-btn"> Load more</button>