-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
117 lines (113 loc) · 4.7 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
try{
$db=new PDO("mysql:host=localhost;dbname=sayfalama;charset=utf8","root","");
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
die($e->getMessage());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SAYFALAMA SİSTEMİ ÖRNEK</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function(e) {
$("#sayi").on('change',function(e) {
var gelendeger=$("#sayi option:selected").val();
$.get("cook.php?tercih=belirle",{"limit":gelendeger},function(){
window.location.reload();
});
});
});
</script>
</head>
<body>
<?php
$cek=$db->prepare("SELECT COUNT(*) AS toplam FROM yazilar");
$cek->execute();
$urunlerson=$cek->fetch(PDO::FETCH_ASSOC);
if (@!isset($_COOKIE["gosterlimit"])) :
$gosterilecekadet=5;
else:
$gosterilecekadet=@$_COOKIE["gosterlimit"];
endif;
$toplamicerik=$urunlerson["toplam"];
$toplamsayfa=ceil($toplamicerik / $gosterilecekadet);
$sayfa= isset($_GET["hareket"]) ? (int) $_GET["hareket"] : 1;
if($sayfa<1) $sayfa=1;
if ($sayfa > $toplamsayfa) $sayfa = $toplamsayfa;
$limit = ($sayfa - 1) * $gosterilecekadet;
$cek2=$db->prepare("select * from yazilar LIMIT $limit,$gosterilecekadet");
$cek2->execute();
?>
<div class="container">
<div class="row">
<div class="col-md-12" id="yinele">
<table class="table table-bordered mt-2 text-center ">
<tbody>
<tr>
<td class="text-left bg-light">
<!-- select box -->
<select id="sayi" class="form-control">
<?php
$sayilar=array(5,10,20,30);
foreach ($sayilar as $deger) :
if ($deger==@$_COOKIE["gosterlimit"]) :
echo '<option value="'.$deger.'" selected="selected">'.$deger.'</option>';
else:
echo '<option value="'.$deger.'">'.$deger.'</option>';
endif;
endforeach;
?>
</select>
</td>
<!-- toplam adet -->
<td class="text-left bg-light">
<div class="alert alert-info col-md-3 float-right">Toplam Veri Sayısı:
<?php echo $urunlerson["toplam"]; ?>
</div>
</td>
</tr>
<!-- konular -->
<tr>
<th style="width:100px;" >Konu no</th>
<th >Konu İçerik</th>
</tr>
</tbody>
<tbody>
<?php
while ($aktar=$cek2->fetch(PDO::FETCH_ASSOC)):
echo '<tr>
<td>'.$aktar["id"].'</td>
<td>'.$aktar["icerik"].'</td>
</tr>';
endwhile;
?>
<tr>
<td colspan="2" class="text-center bg-light" >
<!-- sayfalama -->
<nav aria-label="Page navigation example">
<ul class="pagination mx-auto">
<?php
for ($s=1; $s<=$toplamsayfa; $s++) :
echo '<li class="page-item">
<a class="page-link" href="?hareket='.$s.'">'.$s.'</a>
</li>';
endfor;
?>
</ul>
</nav>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>