Page 1 of 1
Pagination Loader without Database (for pictures)
Posted: 26 Aug 2017, 11:28
by JanMolendijk
Dear ADmin i hope you can help me with my next problem
I have for the members seperated folders for pictures...
But some members have to mutch pictures to load in once
I`m searching for 7 hours for a Pagination Loader without Database for the pictures
Code: Select all
<?php
$files = glob("../images/$users[email]/*.*");
for ($i=0; $i<count($files); $i++)
{
$num = $files[$i];
echo '<div class="col-xs-6 col-md-3">
<div class="thumbnail">
<a href="'.$num.'" rel="shadowbox"><img src="'.$num.'" class="img-responsive" > </a>
<br>
<link href="ratingfiles/ratings.css" rel="stylesheet" type="text/css" />
<div class="srtgs" id="rt_'.$num.'"></div>
<script src="ratingfiles/ratings.js" type="text/javascript"></script>
<div class="caption">
<p></div>
</div>
</div>';
}
?>
</div>
Pagination Loader without Database (for pictures)
Posted: 26 Aug 2017, 14:58
by Admin
Hello,
You can use the Pagination Class from this page:
https://coursesweb.net/php-mysql/paginat ... -script_s2
- It can be used to paginate data from database, items of an array, and even a large content string.
- See the documentation and examples in that page.
Basically, you have to include the class, and to add the array with pictures files to the
getArrRows($files ); method.
- In the class code, in the
public function getArrRows($arr) method define the html you want to render:
Code: Select all
// HERE ADDS HTML TAGS TO FORMAT THE ZONE THAT CONTAINS EACH ELEMENT
for($i=0; $i<$nre; $i++) {
$re_cnt .= '<div class="content">'. $ar_page[$i]. '</div>';
}
- Something like this:
Code: Select all
// HERE ADDS HTML TAGS TO FORMAT THE ZONE THAT CONTAINS EACH ELEMENT
for($i=0; $i<$nre; $i++) {
$re_cnt .='<div class="col-xs-6 col-md-3"><div class="thumbnail">
<a href="'. $ar_page[$i]. '" rel="shadowbox"><img src="'. $ar_page[$i]. '" class="img-responsive" > </a><br>
<div class="srtgs" id="rt_'. $ar_page[$i]. '"></div>
<div class="caption"></div>
</div></div>';
}
$re_cnt .='<link href="ratingfiles/ratings.css" rel="stylesheet" type="text/css" />
<script src="ratingfiles/ratings.js" type="text/javascript"></script>';
return $re_cnt;
Pagination Loader without Database (for pictures)
Posted: 26 Aug 2017, 16:27
by JanMolendijk
Dear Admin In the class code, in the public function getArrRows($arr)
i changed the code like you said
I don`t get it i have the follow code placed into the test_array
but i cant get $id into echo $objPg->getLinks();
the $id i need for the next pagination
Code: Select all
<?php
include('../connection.php');
$id = (int) $_GET['id'];
$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
Code: Select all
<?php
$files = glob("../../images/$users[email]/*.*");
for ($i=0; $i<count($files); $i++)
{
$num = $files[$i];
}
?>
Code: Select all
<?php
// Array with data
$source = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','y','x','z');
// include the Pagination class
include('class.pagination.php');
// create object instance of the class
$objPg = new Pagination();
// if you want to change the number of rows /elements added in page, set the "rowsperpage" property
// $objPg->rowsperpage = 8;
// output /display the conntent
echo $objPg->getArrRows($files);
// output / display pagination links
echo $objPg->getLinks();
?>
Pagination Loader without Database (for pictures)
Posted: 27 Aug 2017, 06:43
by Admin
I updated the class code.
Get again the class from the link added in the previous response, then use this syntax to add an $id in the pagination links:
Code: Select all
$str ='id='.$id;
echo $objPg->getLinks($str);
Pagination Loader without Database (for pictures)
Posted: 27 Aug 2017, 14:36
by JanMolendijk
Thanks for all support again &nd again