login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Problemen met pagination

Offline kadaj - 17/08/2010 21:39 (laatste wijziging 17/08/2010 21:41)
Avatar van kadajNieuw lid Beste gebruikers,

Ik krijg het maar niet werkende om de wallpapers op een pagina te laten tonen met pagination, dit is momenteel mijn code :

Plaatscode: 139859

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://iwallpap...amp;code=5

Dit is de uitleg van het pagination wat ik gebruik:

Citaat:
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


Ik heb de maker van het script gecontacteerd, maar mocht niet baten, dus dacht misschien zit iemand hier zo een fout in mijn code...

7 antwoorden

Gesponsorde links
Offline cyberninjah - 18/08/2010 00:59
Avatar van cyberninjah Lid om er naar te kijken heb ik toch echt die class file nodig .
Zou je deze kunnen plaatsen via plaatscode ?
Offline kadaj - 18/08/2010 09:40
Avatar van kadaj Nieuw lid Waarvoor heb je die code nodig dan, het gaat namelijk mis ergens in de code die ik gaf, hij gooit het terug naar rows, of wil je die regel 53 zien die hij aangeeft?
Offline cyberninjah - 18/08/2010 10:04 (laatste wijziging 18/08/2010 10:05)
Avatar van cyberninjah Lid aangezien het fout gaat in de volgende en vorige button.

in dat stukje code kan ik ze nergens vinden.

wel dat je de class aanroept daarom vroeg ik het

en aangezien dit 1 van je buttons moeten zijn

  1. <span class="pagination_disabled">Next »</span>


Dit is geen link maar kan ook nergens in jou code vinden waar deze gemaakt wordt.
Offline kadaj - 18/08/2010 10:28
Avatar van kadaj Nieuw lid Plaatscode: 139862

Hier de pagination class, hoop dat je kan helpen...
Offline cyberninjah - 18/08/2010 12:04
Avatar van cyberninjah Lid zie niks fouts mischien die anderen .php pagina ook even posten ??
Offline kadaj - 18/08/2010 12:10
Avatar van kadaj Nieuw lid Iemand anders die wel een fout in mijn bovengeplaatste code ziet?
Offline gnotrgnotr - 18/08/2010 20:11
Avatar van gnotrgnotr Nieuw lid volg deze tutorial:
http://www.youtube.com/watch?v=wC0uc_TkdR0
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.186s