TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-08-2008, 01:55 AM   #21 (permalink)
The Wanderer
 
dylanfm's Avatar
 
Join Date: Jan 2008
Location: Australia
Posts: 14
Thanks: 1
dylanfm is on a distinguished road
Default

Never let your offset go beneath 0
Send a message via ICQ to dylanfm
dylanfm is offline  
Reply With Quote
Old 02-08-2008, 01:57 AM   #22 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by dylanfm View Post
Never let your offset go beneath 0
I have this:
PHP Code:
 if ($page 1)
 {
     
$page 1;
 } 
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-08-2008, 02:05 AM   #23 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Success! I Got It But Yet The Numbers Dont Show Up! Only Next! No Prev!
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 02-08-2008, 02:08 AM   #24 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Woot, I got it, but Prev doesnt show!


UPDATE: Prev goes to page 0
In fact, Next just keeps incrementing

In fact, it doesnt show it incrementing numbers on the page, just the url. /?page=% and it keeps showing [1] :[
__________________
VillageIdiot can have my babbies ;d

Last edited by Orc : 02-08-2008 at 02:30 AM.
Orc is offline  
Reply With Quote
Old 02-08-2008, 09:13 AM   #25 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

@Orc.

I have found some nice Pagination tutorials on this site called:
PHP Help: PHP Freaks!

Wich got me going some time back with pagination.
Maybe it could help you.

Seems they removed the Tutorial.
But i found some code snippets in there library
PHP Help: Pagination

/EyeDentify
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
Old 02-08-2008, 10:24 AM   #26 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Various sites offer these classes but the best way is to make your own. Do not be afraid to use if/else 's since that is what they are made for. I know from experience that vBulletin and others have a very good script for what you are trying to do. I myself am going to make on as well but I always do some research into how it's done. I suggest you do the same.

Otherwise, you can check some tutorials on Pixel2Life.com and Tutorialized.com If you don't manage, just post! Hopefully this post will help you sort out some problems, kinda useless post otherwise.

Good luck!
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 02-08-2008, 01:59 PM   #27 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
Various sites offer these classes but the best way is to make your own. Do not be afraid to use if/else 's since that is what they are made for. I know from experience that vBulletin and others have a very good script for what you are trying to do. I myself am going to make on as well but I always do some research into how it's done. I suggest you do the same.

Otherwise, you can check some tutorials on Pixel2Life.com and Tutorialized.com If you don't manage, just post! Hopefully this post will help you sort out some problems, kinda useless post otherwise.

Good luck!
Alright, I'll probably make my own, I just need to understand MySQL a bit more. That's all.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-17-2010, 10:15 PM   #28 (permalink)
The Visitor
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
REFFER is on a distinguished road
Default

Here one simple solution for people looking for pagination...
Just a few changes in the code and it works fine.


PHP Code:
    $max 3;
    if (
is_numeric($_GET['p'])){
        
$p $_GET['p'];
        if (
$p<1$p 1;
    } else {
        
$p 1;
    }
    
    
$limit = ($p $max) - $max;
    
    
$conn mysql_connect("localhost","user","pass");
    
mysql_select_db("db_name",$conn);
    
    
$query_count "SELECT * FROM `table`";
    
$result mysql_query($query_count);
    
$rows = @mysql_num_rows($result);
    
$numOfPages ceil($rows/$max);
    
    if (
$p>$numOfPages$p $numOfPages;
    
    
$query $query_count " LIMIT $limit$max";
    
$result mysql_query($query);
    

    while (
$data mysql_fetch_object($result)){
        echo 
$data->field."<br />";
    }
    
    echo 
"<br /><br />";

    if (
$p>1){
        
$prev $p 1;
        echo 
'<a href="?p='.$prev.'">Previous</a> ';
    }
    for (
$i=1;$i<=$numOfPages;$i++){
        if (
$i == $p){
            echo 
"<b>$i</b> ";
        } else {
            echo 
'<a href="?p='.$i.'">'.$i.'</a> ';
        }
    }
    if (
$p<$numOfPages){
        
$next $p 1;
        echo 
'<a href="?p='.$next.'">Next</a>';
    } 

Last edited by REFFER : 03-18-2010 at 02:13 AM.
REFFER is offline  
Reply With Quote
Old 11-21-2011, 09:32 AM   #29 (permalink)
The Visitor
 
Nicklaus's Avatar
 
Join Date: Nov 2011
Posts: 3
Thanks: 0
Nicklaus is on a distinguished road
Default

I am trying to make a simple site map - from a directory full of files.. but I have too many files in the folder, I need pagination.. I have no idea how to do this without MySQL.

PHP Code:
<?php
$filearray = array(); if ($fil = opendir("directory/")) {
while (($file = readdir($fil)) !== false) {
if ($file != "." && $file != "..") { $filearray[] = $file;
echo "<a href="http://www.mydomain.com/directory/$file">http://www.mydomain.com/directory/$file</a><br>";
[code]...
Nicklaus is offline  
Reply With Quote
Old 11-21-2011, 10:58 AM   #30 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

Quote:
Originally Posted by Nicklaus View Post
I am trying to make a simple site map - from a directory full of files.. but I have too many files in the folder, I need pagination.. I have no idea how to do this without MySQL.

PHP Code:
<?php
$filearray = array(); if ($fil = opendir("directory/")) {
while (($file = readdir($fil)) !== false) {
if ($file != "." && $file != "..") { $filearray[] = $file;
echo "<a href="http://www.mydomain.com/directory/$file">http://www.mydomain.com/directory/$file</a><br>";
[code]...
Perhaps you could cache the "file listing" in a textfile and then make use of it in an array thereby be able to paginate it ?

And have a look at this function:
http://se.php.net/manual/en/function.glob.php

Itīs often underestimated.

Good luck.
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:57 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design