Username:    Password:        Click Here To Signup     Forgotten Password
Main Menu
Online
Members: 1

Guests: 13

111.73.x.x comment
175.44.x.x forum
193.142.x.x download
199.21.x.x forum
220.161.x.x signup
220.250.x.x forum
23.22.x.x forum
36.248.x.x forum
37.128.x.x download
54.226.x.x forum
66.249.x.x user
79.113.x.x request
96.49.x.x news

Last Seen

Wussie Wed 09:38
palyarmerc Wed 09:10
Hostprofil Wed 08:17
Zipps Wed 06:42
code72 Wed 05:56

Newest Members

Forums
UPDATE! Simple pagination for LGSL
KIKOFF
Sat Jan 29 2011, 04:43PM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
NEW
Hi all, I leave a better script than the last. Same procedure...


<?php
    
    $limit 
20;

    
$tableName "{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}";
    
$targetpage "index.php";
    
$output .= "";

    
$query "SELECT COUNT(*) as num FROM $tableName";
    
$total_pages mysql_fetch_array(mysql_query($query));
    
$total_pages $total_pages['num'];

    
$stages 3;

    if (!isset(
$_GET['page'])) { $_GET['page'] = 0;} else {$page $_GET['page'];}
    
$page mysql_escape_string($_GET['page']);
    if(
$page){
        
$start = ($page 1) * $limit;
    }else{
        
$start 0;
        }

    
// Get page data
    
$query1 "SELECT * FROM $tableName LIMIT $limit";
    
$result mysql_query($query1);

    
// Initial page num setup
    
if ($page == 0){$page 1;}
    
$prev $page 1;
    
$next $page 1;
    
$lastpage ceil($total_pages/$limit);
    
$LastPagem1 $lastpage 1;        

$output .= "<div style='text-align:center;width:100%;'>";
    
$paginate '';
    if(
$lastpage 1)
    {
        
$paginate .= "<div class='paginate'>";
        
// Previous
        
if ($page 1){
            
$paginate.= "<a class='button' href='$targetpage?page=$prev'><</a>";
        }
        else{
            
$paginate.= "<span class='disabled'><</span>";    }

        
// Pages
        
if ($lastpage + ($stages 2))    // Not enough pages to breaking it up
        
{
            for (
$counter 1$counter <= $lastpage$counter++)
            {
                if (
$counter == $page){
                    
$paginate.= "<span class='current'>$counter</span>";
                }else{
                    
$paginate.= "<a class='button' href='$targetpage?page=$counter'>$counter</a>";}
            }
        }
        elseif(
$lastpage + ($stages 2))    // Enough pages to hide a few?
        
{
        
// Beginning only hide later pages
            
if($page + ($stages 2))
            {
                for (
$counter 1$counter + ($stages 2); $counter++)
                {
                    if (
$counter == $page){
                        
$paginate.= "<span class='current'>$counter</span>";
                    }else{
                        
$paginate.= "<a class='button' href='$targetpage?page=$counter'>$counter</a>";}
                }
                
$paginate.= "...";
                
$paginate.= "<a class='button' href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                
$paginate.= "<a class='button' href='$targetpage?page=$lastpage'>$lastpage</a>";
            }
        
// Middle hide some front and some back
            
elseif($lastpage - ($stages 2) > $page && $page > ($stages 2))
            {
                
$paginate.= "<a class='button'  href='$targetpage?page=1'>1</a>";
                
$paginate.= "<a class='button'  href='$targetpage?page=2'>2</a>";
                
$paginate.= "...";
                for (
$counter $page $stages$counter <= $page $stages$counter++)
                {
                    if (
$counter == $page){
                        
$paginate.= "<span class='current'>$counter</span>";
                    }else{
                        
$paginate.= "<a class='button' href='$targetpage?page=$counter'>$counter</a>";}
                }
                
$paginate.= "...";
                
$paginate.= "<a class='button' href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                
$paginate.= "<a class='button' href='$targetpage?page=$lastpage'>$lastpage</a>";        
            }
        
// End only hide early pages
            
else
            {
                
$paginate.= "<a class='button' href='$targetpage?page=1'>1</a>";
                
$paginate.= "<a class='button' href='$targetpage?page=2'>2</a>";
                
$paginate.= "...";
                for (
$counter $lastpage - (+ ($stages 2)); $counter <= $lastpage$counter++)
                {
                    if (
$counter == $page){
                        
$paginate.= "<span class='current'>$counter</span>";
                    }else{
                        
$paginate.= "<a class='button' href='$targetpage?page=$counter'>$counter</a>";}
                }
            }
        }
        
// Next
            
if ($page $counter 1){
                
$paginate.= "<a class='button' href='$targetpage?page=$next'>></a>";
            }else{
            
$paginate.= "<span class='disabled'>></span>";
            }
                
$paginate.= "</div>";
            }
$output .= "<div class='result'>".$total_pages.' Servers'."</div>";
 
// Pagination
$output .= "$paginate";
$output .= "</div>";


Open lgsl_class.php and find:

$mysql_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY {$mysql_order}";
$mysql_result = mysql_query($mysql_query) or die(mysql_error());


And replace with this:

if(!isset($_GET['page'])) { $page = 1; } else { $page = $_GET['page']; }
$limit = (($page * 20) - 20);
$mysql_result = mysql_query("SELECT * FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY {$mysql_order} LIMIT $limit, 20") or die(mysql_error());


Open lgsl_list and put this code where you like to show pagination:

require "lgsl_pagination.php";


A little style:

.paginate {
  margin:5px;
  text-align:right;
  }
.button {
  background-color:#f4f4f4;
  border:1px solid #ddd;
  text-decoration:none;
  padding:2px 5px;
  margin:0 2px;
}
.disabled {
  background-color:#ccc;
  border:1px solid #ddd;
  text-decoration:none;
  color:#ddd;
  padding:2px 5px;
  margin:0 2px;
}
.current {
  background-color:#e4eaf2;
  border:1px solid #ddd;
  text-decoration:none;
  padding:2px 5px;
  margin:0 2px;
  }
.result {
  float:left;
  margin-left:5px;
}


Enjoy!

OLD SCRIPT

Hi all, here I leave a code for simple pagination.

Create a php file called lgsl_pagination.php with this:

<?php
$pages
=$_GET['page'];

$limit=20;

$mysql_result mysql_query("SELECT * FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}`");
    
    
$nrResults=mysql_num_rows($mysql_result);
    
    if ((
$nrResults%$limit)<>0) {
        
$pmax=floor($nrResults/$limit)+1;
    } else {
        
$pmax=floor($nrResults/$limit);
    }
    
$output .= "<br/><div style='text-align: right;'>";

    if(
$pages 1)
    {
$prevp="<a class='button' href='index.php?page=".($pages-1)."' title='Previous Page'><<</a>";
    }
    else
    {
    
$output .= "";
    }    
$output .= "$prevp"

    
$pid=1
    while (
$pid<=$pmax)
    { 
$paging"<a class='button' href='index.php?page=$pid' title='Page $pid of $pmax'>$pid</a>";

$newpaging=str_replace("<a class='button' href='index.php?page=$pages' title='Page $pages of $pmax'> $pages</a>""<span>$pages</span>"$paging);
$output .= $newpaging";
                            
    
$pid++;
    }  
    if(
$pages $pmax)
    {
$nextp="<a class='button' href='index.php?page=".($pages+1)."' title='Next Page'>>></a>";
    }
    else
    {
    
$output .= "";
    }    
$output .= "$nextp";
$output .= "<a class='button' href='index.php?page=$pmax' title='Last Page'>Last Page</a>";
$output .= "<span style='float: left;font-weight: bold;'>Page $pages of $pmax</span>";
$output .= "</div><br/>";


Open lgsl_class.php and find:

$mysql_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY {$mysql_order}";
$mysql_result = mysql_query($mysql_query) or die(mysql_error());


And replace with this:

if(!isset($_GET['page'])) { $page = 1; } else { $page = $_GET['page']; }
$limit = (($page * 20) - 20);
$mysql_result = mysql_query("SELECT * FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY id LIMIT $limit, 20") or die(mysql_error());


Open lgsl_list and put this code where you like to show pagination:

include "lgsl_pagination.php";




PD: I tested only with e107 version.


Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
xMin
Wed Mar 09 2011, 05:07PM
Posts: 54
Joined: Fri Mar 04 2011, 08:41AM
Registered Member #6619
Hi. KIKOFF

Can you please send me your lgsl_pagination.php and lgls_list.php files ? Ihave some errors.. (pm-ed you about that..)

Please and THANKS!!!
KIKOFF
Sun Mar 13 2011, 09:10AM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
GTrs wrote ...

Hi. KIKOFF

Can you please send me your lgsl_pagination.php and lgls_list.php files ? Ihave some errors.. (pm-ed you about that..)

Please and THANKS!!!

I've sent you a PM

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
KIKOFF
Sun Mar 13 2011, 10:09AM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
For what they use SA, must define nextp and prevp...

Before prevp lines:
$prevp = (isset($prevp)) ? $prevp : '';

And for nextp:
$nextp = (isset($nextp)) ? $nextp : '';


And of course the link to lgsl must
index.php?page=1

Saludos

PD: sorry for bdoble post

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
xMin
Sun Mar 13 2011, 10:45AM
Posts: 54
Joined: Fri Mar 04 2011, 08:41AM
Registered Member #6619
Thanks for fix but still there is the problem on line 2:

$pages=$_GET['page'];

Notice: Undefined index: page in ...\lgsl_files\lgsl_pagination.php on line 2

I sent you a PM..
KIKOFF
Sun Jun 26 2011, 07:29AM

Posts: 132
Joined: Thu Nov 18 2010, 08:18AM
Registered Member #6411
Update!

Lo cortez, no quita lo valiente... ahhh... yes e107 Rock
Dodgeitorelse
Sun Jun 26 2011, 08:20AM
Posts: 175
Joined: Sun Dec 12 2010, 09:16AM
Registered Member #6457
nice Kikoff, well done

~Salutations
Website
Jygnas
Sun Feb 12 2012, 08:26AM
Posts: 12
Joined: Thu Apr 28 2011, 07:31AM
Registered Member #6714
Hello, my code is not lgsl_class.php

Open lgsl_class.php and find:

$mysql_query = "SELECT `id` FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY {$mysql_order}";
$mysql_result = mysql_query($mysql_query) or die(mysql_error());


And replace with this:

if(!isset($_GET['page'])) { $page = 1; } else { $page = $_GET['page']; }
$limit = (($page * 20) - 20);
$mysql_result = mysql_query("SELECT * FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE ".implode(" AND ", $mysql_where)." ORDER BY {$mysql_order} LIMIT $limit, 20") or die(mysql_error()); 







my code is lgsl_class.php

    $mysql_query  = "SELECT * FROM `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` WHERE `ip` = '$ip' AND `q_port` = '$q_port' AND `type` = '$type' LIMIT 1";
    $mysql_result = mysql_query($mysql_query) or die(mysql_error());
    $mysql_row    = mysql_fetch_array($mysql_result, MYSQL_ASSOC);

    // CHECK IF SERVER IS IN THE DATABASE AND ADD IF REQUESTED

    if (!$mysql_row)
    {
      if (strpos($request, "a") !== FALSE)
      {
        $mysql_query     = "INSERT INTO `{$lgsl_config['db']['prefix']}{$lgsl_config['db']['table']}` (`ip`, `q_port`, `c_port`, `s_port`, `type`, `cache`, `cache_time`) VALUES ('$ip', '$q_port', '$c_port', '$s_port', '$type', '', '')";
        $mysql_result    = mysql_query($mysql_query) or die(mysql_error());
        $mysql_row['id'] = mysql_insert_id();
      }
      else
      {
        echo "LGSL PROBLEM: REQUESTED SERVER NOT IN DATABASE: '$ip:$q_port:$c_port:$s_port:$type:$request'"; exit;
      }
    }


how to make the groups pages? pages is /index.php?stype=1&type=halflife , /index.php?stype=2&type=halflife
Website
C0n
Tue Sep 18 2012, 11:29AM
Posts: 33
Joined: Tue Nov 03 2009, 01:54AM
Registered Member #5538
Your code is extremely long for something that is so simple....

http://www.greycube.com/site/e107_plugins/forum/forum_viewtopic.php?12376.post

C0n

Live Steam Server List tracking over 1million servers http://www.steam-hacks.com/servers.html Listing more servers than gametracker and game-monitor
Website
 

Jump:     Back to top


You are not logged in - Click Here To Signup

Username:    Password:   

Mini Buttons

.... © GreyCube.com - Richard Perry - Powered by e107.org