Delete
Delete pagination
This commit is contained in:
187
-child/Pagination/load_data.php
Executable file
187
-child/Pagination/load_data.php
Executable file
@@ -0,0 +1,187 @@
|
||||
<style type="text/css">
|
||||
/*found on http://www.brunildo.org/test/img_center.html*/
|
||||
.wraptocenter {
|
||||
display: table-cell!important;
|
||||
text-align: center!important;
|
||||
vertical-align: middle!important;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
.wraptocenter * {
|
||||
vertical-align: middle!important;
|
||||
}
|
||||
/*\*//*/
|
||||
.wraptocenter {
|
||||
display: block;
|
||||
}
|
||||
.wraptocenter span {
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
}
|
||||
/**/
|
||||
</style>
|
||||
<!--[if IE]><style>
|
||||
.wraptocenter span {
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
}
|
||||
</style><![endif]-->
|
||||
</style>
|
||||
|
||||
<?php
|
||||
if($_POST['page'])
|
||||
{
|
||||
$page = $_POST['page'];
|
||||
$cur_page = $page;
|
||||
$page -= 1;
|
||||
$per_page = 15;
|
||||
$previous_btn = true;
|
||||
$next_btn = true;
|
||||
$first_btn = true;
|
||||
$last_btn = true;
|
||||
$start = $page * $per_page;
|
||||
include("db.php");
|
||||
include("fonctions.php");
|
||||
|
||||
$album = 'photos-du-mois'; //Photos du mois
|
||||
$item_per_page = 12; //item to display per page
|
||||
|
||||
$table = array();
|
||||
if ($_SERVER['HTTP_HOST'] == "macbook-pro.local") {
|
||||
$table['images'] = ".images";
|
||||
$table['albums'] = ".albums";
|
||||
}
|
||||
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
|
||||
$table['images'] = "zenphoto_images";
|
||||
$table['albums'] = "zenphoto_albums";
|
||||
}
|
||||
|
||||
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
|
||||
//Output any connection error
|
||||
if ($mysqli->connect_error) {
|
||||
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
|
||||
}
|
||||
|
||||
|
||||
// Récupérer l'ID de l'album 'photos-du-mois' ($id_album)
|
||||
$i = 0;
|
||||
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);
|
||||
if ($conn->connect_error) {
|
||||
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
|
||||
exit();
|
||||
}
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
$excquery = "SELECT `id` FROM `" . $table['albums'] . "` WHERE `folder` = '" . $album . "'";
|
||||
|
||||
if ($result = $conn->query($excquery)) {
|
||||
$result->data_seek(0);
|
||||
$row = $result->fetch_row();
|
||||
$id_album = $row[0];
|
||||
$result->close();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
/*
|
||||
$query_pag_data = "SELECT msg_id,message from messages LIMIT $start, $per_page";
|
||||
$result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error());
|
||||
$msg = "";
|
||||
while ($row = mysql_fetch_array($result_pag_data)) {
|
||||
$htmlmsg=htmlentities($row['message']);
|
||||
$msg .= "<li><b>" . $row['msg_id'] . "</b> " . $htmlmsg . "</li>";
|
||||
}
|
||||
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
|
||||
*/
|
||||
$msg = "";
|
||||
|
||||
//Limit our results within a specified range.
|
||||
$results = $mysqli->prepare("SELECT `filename` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC LIMIT $start, $per_page");
|
||||
$results->bind_param('i', $id_album);
|
||||
$results->execute(); //Execute prepared Query
|
||||
$results->bind_result($filename); //bind variables to prepared statement
|
||||
|
||||
//Display records fetched from database.
|
||||
while($results->fetch()){ //fetch values
|
||||
//$msg .= "<li><b>" . $filename . "</b></li>";
|
||||
$msg .= displayRetina($filename,$album);
|
||||
}
|
||||
//$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
|
||||
|
||||
|
||||
/* ---------------------------------------------
|
||||
$query_pag_num = "SELECT COUNT(*) AS count FROM messages";
|
||||
$result_pag_num = mysql_query($query_pag_num);
|
||||
$row = mysql_fetch_array($result_pag_num);
|
||||
$count = $row['count'];
|
||||
*/
|
||||
|
||||
$results = $mysqli->query("SELECT COUNT(*) FROM `" . $table['images'] . "` WHERE `albumid` = $id_album ");
|
||||
$count = $results->fetch_row(); //hold total records in variable
|
||||
|
||||
$no_of_paginations = ceil($count[0] / $per_page);
|
||||
|
||||
/* ---------------Calculating the starting and endign values for the loop----------------------------------- */
|
||||
if ($cur_page >= 7) {
|
||||
$start_loop = $cur_page - 3;
|
||||
if ($no_of_paginations > $cur_page + 3)
|
||||
$end_loop = $cur_page + 3;
|
||||
else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
|
||||
$start_loop = $no_of_paginations - 6;
|
||||
$end_loop = $no_of_paginations;
|
||||
} else {
|
||||
$end_loop = $no_of_paginations;
|
||||
}
|
||||
} else {
|
||||
$start_loop = 1;
|
||||
if ($no_of_paginations > 7)
|
||||
$end_loop = 7;
|
||||
else
|
||||
$end_loop = $no_of_paginations;
|
||||
}
|
||||
/* ----------------------------------------------------------------------------------------------------------- */
|
||||
$msg .= "<div class='pagination'><ul>";
|
||||
|
||||
// FOR ENABLING THE FIRST BUTTON
|
||||
if ($first_btn && $cur_page > 1) {
|
||||
$msg .= "<li p='1' class='active'>First</li>";
|
||||
} else if ($first_btn) {
|
||||
$msg .= "<li p='1' class='inactive'>First</li>";
|
||||
}
|
||||
|
||||
// FOR ENABLING THE PREVIOUS BUTTON
|
||||
if ($previous_btn && $cur_page > 1) {
|
||||
$pre = $cur_page - 1;
|
||||
$msg .= "<li p='$pre' class='active'>Previous</li>";
|
||||
} else if ($previous_btn) {
|
||||
$msg .= "<li class='inactive'>Previous</li>";
|
||||
}
|
||||
for ($i = $start_loop; $i <= $end_loop; $i++) {
|
||||
|
||||
if ($cur_page == $i)
|
||||
$msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
|
||||
else
|
||||
$msg .= "<li p='$i' class='active'>{$i}</li>";
|
||||
}
|
||||
|
||||
// TO ENABLE THE NEXT BUTTON
|
||||
if ($next_btn && $cur_page < $no_of_paginations) {
|
||||
$nex = $cur_page + 1;
|
||||
$msg .= "<li p='$nex' class='active'>Next</li>";
|
||||
} else if ($next_btn) {
|
||||
$msg .= "<li class='inactive'>Next</li>";
|
||||
}
|
||||
|
||||
// TO ENABLE THE END BUTTON
|
||||
if ($last_btn && $cur_page < $no_of_paginations) {
|
||||
$msg .= "<li p='$no_of_paginations' class='active'>Last</li>";
|
||||
} else if ($last_btn) {
|
||||
$msg .= "<li p='$no_of_paginations' class='inactive'>Last</li>";
|
||||
}
|
||||
$goto = "<input type='text' class='goto' size='1' style='margin-top:-1px;margin-left:60px;'/><input type='button' id='go_btn' class='go_button' value='Go'/>";
|
||||
$total_string = "<span class='total' a='$no_of_paginations'>Page <b>" . $cur_page . "</b> of <b>$no_of_paginations</b></span>";
|
||||
$msg = $msg . "</ul>" . $total_string . "</div>"; // Content for pagination
|
||||
echo $msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user