Hey Guys,
Im making a gallery with PHP pagination system.. now im not good at PHP and ripped the pagination script from a site!
What i have is this
Now i have a problem, i made this working from MYSQL Database if i insert a photo link it should work! but the problem is, if the page is ful at limit 20, it opens a new page but the new page doesnt contain new images from the DB it still picks the 20 from the first page. It just duplicates...
Is there someone that can fix this?
Table looks like this...
ID PHOTO_LINK PHOTO_DESC
1 /templates/../../../../../../4r24u0er8jd.jpg This is a photo
I hope someone can fix this. Thanks
With best regards,
C0MB4T
Im making a gallery with PHP pagination system.. now im not good at PHP and ripped the pagination script from a site!
What i have is this
PHP:
<?php
$num_rec_per_page=20;
mysql_connect('localhost','root','***********');
mysql_select_db('*********');
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$sql = "SELECT * FROM gallerij LIMIT $start_from, $num_rec_per_page";
$rs_result = mysql_query ($sql); //run the query
?>
<table>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
?>
<tr style="display:inline-block">
<td>
<div class="gallery">
<div class="gallery-border">
<div class="desc-border">
<img onclick="onClick(this)" class="img-opacity" src="<?php echo $row['photo_link']; ?>" alt="Afbeelding" width="300" height="200"> </div>
<div class="desc"><?php echo $row['photo_desc']; ?></div>
</div>
</div>
</td>
</tr>
<?php
};
?>
</table>
<center>
<div class="pagination">
<?php
$sql = "SELECT * FROM gallerij";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result); //count number of records
$total_pages = ceil($total_records / $num_rec_per_page);
echo "<a href='indexgallerij?page=1'>".'«'."</a> "; // Goto 1st page
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='indexgallerij?page=".$i."'>".$i."</a> ";
};
echo "<a href='indexgallerij?page=$total_pages'>".'»'."</a> "; // Goto last page
?>
</div>
Now i have a problem, i made this working from MYSQL Database if i insert a photo link it should work! but the problem is, if the page is ful at limit 20, it opens a new page but the new page doesnt contain new images from the DB it still picks the 20 from the first page. It just duplicates...
Is there someone that can fix this?
Table looks like this...
ID PHOTO_LINK PHOTO_DESC
1 /templates/../../../../../../4r24u0er8jd.jpg This is a photo
I hope someone can fix this. Thanks
With best regards,
C0MB4T