Pagination probleem
Ik krijg het maar niet werkende om de wallpapers op een pagina te laten tonen met pagination, dit is momenteel mijn code :
Code (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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<td class="tableback"> <?php
$pagination = new Pagination($limit, $rows, $page, $location);
if(isset($_GET['code'])){
$code=$_GET['code'];
$start = $pagination->prePagination();
$cat = mysql_query("SELECT * FROM iphone WHERE code='".mysql_real_escape_string($code)."'ORDER BY id DESC LIMIT $start, 12");
$rows = mysql_num_rows($cat);
while($row = mysql_fetch_array($cat)) {
?>
<div class="wallpaper-iphonepreview"><a href="achtergrond_iphone4.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><img class="wallpaper" src="./iphonethumb/<?php echo $row['thumb']; ?>" alt="<?php echo $row['naam']; ?>" /></a>
<h4><?php echo $row['naam']; ?></h4>
<a class="view-link" href="achtergrond_iphone3.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><?php echo $row['naam']; ?></a>
<a class="view1-link" href="achtergrond_iphone4.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><?php echo $row['naam']; ?></a></div>
<?php
}
}
?>
<?
$pagination->pagination();
?>
$pagination = new Pagination($limit, $rows, $page, $location);
if(isset($_GET['code'])){
$code=$_GET['code'];
$start = $pagination->prePagination();
$cat = mysql_query("SELECT * FROM iphone WHERE code='".mysql_real_escape_string($code)."'ORDER BY id DESC LIMIT $start, 12");
$rows = mysql_num_rows($cat);
while($row = mysql_fetch_array($cat)) {
?>
<div class="wallpaper-iphonepreview"><a href="achtergrond_iphone4.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><img class="wallpaper" src="./iphonethumb/<?php echo $row['thumb']; ?>" alt="<?php echo $row['naam']; ?>" /></a>
<h4><?php echo $row['naam']; ?></h4>
<a class="view-link" href="achtergrond_iphone3.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><?php echo $row['naam']; ?></a>
<a class="view1-link" href="achtergrond_iphone4.php?view=<?php echo $row['id']; ?>&naam=<?php echo $row['naam']; ?>"><?php echo $row['naam']; ?></a></div>
<?php
}
}
?>
<?
$pagination->pagination();
?>
Momenteel werkt het al half, hij laat 12 wallpapers zien, zitten er veel meer in die categorie, maar ik kan niet next en prev aanklikken. Zie --> http://iwallpaper.eu/wallpaper-test.php?page&code=1
Dit is de uitleg van het pagination wat ik gebruik:
Quote:
This pagination script was designed with modularity in mind. It is extremely easy to add it all over your website without editing any code whatsoever.
To begin, upload all the files and folders located in the “uploads” directory to your site’s main directory or the directory you wish to use pagination.
In your html head tags, add this code snippet:
<link href="PATH/TO/pagination.css" rel="stylesheet" type="text/css" media="screen" />
Make sure you replace the “PATH/TO” to the path where the pagination.css is actually located.
Once the files are uploaded, include this code snippet in the file you wish to use pagination:
define("IN_PAGI", true);
require("PATH/TO/class_pagination.php");
//grab the current page
$page = intval($_GET['page']);
//set the page if empty
if(empty($page))
{
$page = 1;
}
Make sure to change the PATH/TO/ to the actual path location the class_pagination.php file is located.
The above code snippet defines IN_PAGI so the pagination class can run, then we include the pagination
class. The variable page grabs the current page; no need to worry about the URL’s yourself, the .tpl file takes care of that for you. The if control structure checks if the variable page is empty, and sets the
default page, nothing to worry about there.
Next, add this code snippet above where your query to paginate the data (do not grab the data from the query, this is only used to grab the total number of rows returned, read below):
$pagination = new Pagination($limit, $rows, $page, $location);
After instantiating the class, the first parameter takes how many results you want per page.
The second parameter takes the total amount of rows that are pulled out. If you are using MySQL, you run your select query, then a mysql_num_rows function to select the total rows your query grabbed.
That total should be placed in the second parameter.
The third parameter is your current page, leave that set to the $page variable as that is what we used
earlier.
The fourth and last parameter is your current location. In other words, the URL of where you are at WITHOUT a trailing slash. This is used to append the current page to the URL when the pagination runs.
For example, your location could be:
http://yoursite.com/index.php?action=wallpapers
OR
http://yoursite.com/index.php
If it is the first example we used, make sure you add this &page to the end of it as shown below:
http://yoursite...p;amp;page
If it is the second example used, add this ?page to the end of it as shown below:
http://yoursite.com/index.php?page
Now this URL would be the location parameter, the pagination script would do the rest.
Now add this code snippet right before you run your actual query, remember, the other query was just
to grab the total rows, and not to delimit how many rows to display:
$start = $pagination->prePagination();
If you’re using MySQL, add this code snippet to the end of your SQL query:
LIMIT $start, 12
This will set the limit and what data to pull out. Change the number 12 to the number you set on how many rows you want per page.
Now for the final step, add this code snippet to where you want the pagination to appear (make sure
it’s under all the code we just added):
$pagination->pagination();
Success!
You now have your pagination running, follow the same steps except the uploading steps to add the pagination to other parts of your site. If you want to modify the tpl file, read below to learn its
functionalities
To begin, upload all the files and folders located in the “uploads” directory to your site’s main directory or the directory you wish to use pagination.
In your html head tags, add this code snippet:
<link href="PATH/TO/pagination.css" rel="stylesheet" type="text/css" media="screen" />
Make sure you replace the “PATH/TO” to the path where the pagination.css is actually located.
Once the files are uploaded, include this code snippet in the file you wish to use pagination:
define("IN_PAGI", true);
require("PATH/TO/class_pagination.php");
//grab the current page
$page = intval($_GET['page']);
//set the page if empty
if(empty($page))
{
$page = 1;
}
Make sure to change the PATH/TO/ to the actual path location the class_pagination.php file is located.
The above code snippet defines IN_PAGI so the pagination class can run, then we include the pagination
class. The variable page grabs the current page; no need to worry about the URL’s yourself, the .tpl file takes care of that for you. The if control structure checks if the variable page is empty, and sets the
default page, nothing to worry about there.
Next, add this code snippet above where your query to paginate the data (do not grab the data from the query, this is only used to grab the total number of rows returned, read below):
$pagination = new Pagination($limit, $rows, $page, $location);
After instantiating the class, the first parameter takes how many results you want per page.
The second parameter takes the total amount of rows that are pulled out. If you are using MySQL, you run your select query, then a mysql_num_rows function to select the total rows your query grabbed.
That total should be placed in the second parameter.
The third parameter is your current page, leave that set to the $page variable as that is what we used
earlier.
The fourth and last parameter is your current location. In other words, the URL of where you are at WITHOUT a trailing slash. This is used to append the current page to the URL when the pagination runs.
For example, your location could be:
http://yoursite.com/index.php?action=wallpapers
OR
http://yoursite.com/index.php
If it is the first example we used, make sure you add this &page to the end of it as shown below:
http://yoursite...p;amp;page
If it is the second example used, add this ?page to the end of it as shown below:
http://yoursite.com/index.php?page
Now this URL would be the location parameter, the pagination script would do the rest.
Now add this code snippet right before you run your actual query, remember, the other query was just
to grab the total rows, and not to delimit how many rows to display:
$start = $pagination->prePagination();
If you’re using MySQL, add this code snippet to the end of your SQL query:
LIMIT $start, 12
This will set the limit and what data to pull out. Change the number 12 to the number you set on how many rows you want per page.
Now for the final step, add this code snippet to where you want the pagination to appear (make sure
it’s under all the code we just added):
$pagination->pagination();
Success!
You now have your pagination running, follow the same steps except the uploading steps to add the pagination to other parts of your site. If you want to modify the tpl file, read below to learn its
functionalities
Ik heb de maker van het script gecontacteerd, maar mocht niet baten, dus dacht misschien zit iemand hier zo een fout in mijn code...
Klopt, allen vorige ging mis, deze word ook door de mods verwijderd, zoals je ziet ging daar de opmaak totaal mis, en kon ik deze neit wijzigen, kreeg ik foutmelding