Paging script

Paging script

am 30.09.2009 12:21:23 von ANGELO ZANETTI

Hi All,

I am looking for a paging script, not the normal type but slightly
different. It must show as follows:

1 2 3 ... 12

Then:

1 ... 678 ... 12

And

1 ... 10 11 12

I have googled and not really found much and don't really want to reinvent
the wheel. I am sure I can write my own but due to time constraints ill like
to get a script that will assist me.

Thanks in advance
http://www.wapit.co.za
http://www.elemental.co.za



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Paging script

am 30.09.2009 12:40:28 von Mert Oztekin

Sorry but I dont understand what you mean. Can you be more specific?

{1} 2 3 ... 12 (Startup / Total 12 pages)
When you click 7
1 ... 6 {7} 8 ... 12
When you click 11 or 12
1 ... 10 11 {12}

Do you mean something like this?


-----Original Message-----
From: Angelo Zanetti [mailto:angelo@elemental.co.za]
Sent: Wednesday, September 30, 2009 1:21 PM
To: php-general@lists.php.net
Subject: [PHP] Paging script


Hi All,

I am looking for a paging script, not the normal type but slightly
different. It must show as follows:

1 2 3 ... 12

Then:

1 ... 678 ... 12

And

1 ... 10 11 12

I have googled and not really found much and don't really want to reinvent
the wheel. I am sure I can write my own but due to time constraints ill lik=
e
to get a script that will assist me.

Thanks in advance
http://www.wapit.co.za
http://www.elemental.co.za



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir v=
e gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendirin=
iz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili o=
larak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketi=
miz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?nda=
n, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bil=
gisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individu=
al(s) stated in this message. If you received this message in error, please=
immediately notify the sender and delete it from your system. Our company =
has no legal responsibility for the contents of the message and its attachm=
ents. Our company shall have no liability for any changes or late receiving=
, loss of integrity and confidentiality, viruses and any damages caused in =
anyway to your computer system.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Paging script

am 30.09.2009 12:59:22 von ANGELO ZANETTI

-----Original Message-----
From: Mert Oztekin [mailto:moztekin@anadolusigorta.com.tr]
Sent: 30 September 2009 12:40 PM
To: 'Angelo Zanetti'; php-general@lists.php.net
Subject: RE: [PHP] Paging script

Sorry but I dont understand what you mean. Can you be more specific?

{1} 2 3 ... 12 (Startup / Total 12 pages)
When you click 7
1 ... 6 {7} 8 ... 12
When you click 11 or 12
1 ... 10 11 {12}

Do you mean something like this?


Hi Mert,

Yes I mean exactly like you have it there,

Regards
Angelo



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Paging script

am 30.09.2009 13:05:50 von Ashley Sheridan

On Wed, 2009-09-30 at 12:59 +0200, Angelo Zanetti wrote:
>
> -----Original Message-----
> From: Mert Oztekin [mailto:moztekin@anadolusigorta.com.tr]
> Sent: 30 September 2009 12:40 PM
> To: 'Angelo Zanetti'; php-general@lists.php.net
> Subject: RE: [PHP] Paging script
>
> Sorry but I dont understand what you mean. Can you be more specific?
>
> {1} 2 3 ... 12 (Startup / Total 12 pages)
> When you click 7
> 1 ... 6 {7} 8 ... 12
> When you click 11 or 12
> 1 ... 10 11 {12}
>
> Do you mean something like this?
>
>
> Hi Mert,
>
> Yes I mean exactly like you have it there,
>
> Regards
> Angelo
>
>
>

I'd just code it yourself, the logic behind it is pretty simple.

* The numbers 1 and 12 (the total) will always display
* The page you are on will display the number to either side of
it, unless that is 1 or 12 (the total)
* If the page you are on is 2 or 11 (one less than the total) then
add in '...' on either side of the middle block.



Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Paging script

am 30.09.2009 13:22:30 von Ruben Crespo

--00151761ca582244870474c9bf22
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi all,

Maybe it is not just what you need but could be helpfull.

Here you have the code:

//-------------------paginator.php-------------------------- ---------------=
-----------------------------------
function paginator ($current, $total, $per_page, $link, $limit) {

if ($current == '')
{
$current =3D 1;
}else{
$current =3D $current;
}

$total_pages =3D ceil($total/$per_page);
$previous =3D $current - 1;
$next =3D $current + 1;


/*traduction*/
$toFrom =3D "

Page ".$current." of ".$total_pages."

";
$Goto =3D "Go to Page";
$go =3D "Go";


$texto =3D "
".$toFrom."
    ";

    if ($current > 1)
    $texto .=3D "
  • ";
    else
    $texto .=3D "
  • «
  • ";


    //Se lista hasta llegar a la posici=F3n actual
    if ($current > $limit) {
    $start =3D ($current - $limit) + 1;
    $texto .=3D "
  • ...
  • ";
    } else {
    $start =3D 1;
    }

    for ($start; $start < $current; $start++) {
    $texto .=3D "
  • ";
    }

    //mostramos posicion actual
    $texto .=3D "
  • $current
  • ";

    //mostramos resto de registros
    for ($i=3D$current+1; $i<=3D$total_pages; $i++) {

    if ($i > $limit)
    {
    $texto .=3D "
  • ...
  • ";
    $i =3D $total_pages;
    }else{
    $texto .=3D "
  • ";
    }
    }

    if ($current < $total_pages)
    {
    $texto .=3D "
  • ";
    }else{
    $texto .=3D "
  • »
  • ";
    }

    $texto .=3D "
";


//a form to go directly to the page you want
$texto .=3D '



'.$Goto.' e=3D"" />




';



$texto .=3D '



';

return $texto;

}

?>
//-------------------paginator.php-------------------------- ---------------=
-----------------------------------

//-------------------example.php---------------------------- ---------------=
---------------------------------
include ("paginator.php");

for ($n=3D0; $n<=3D100; $n++)
{
$myArray [$n] =3D $n;
}

$total =3D count ($myArray); //the total elements in the array
$per_page =3D 5; //elements the script show
$link =3D "example.php?page=3D"; //link
$limit =3D 3; //number of items you show in the paginator list



if ($_GET["page"])
{
$current =3D $_GET["page"];
}else{
$current =3D $_POST["page"];
}

$start =3D ($current-1) * $per_page;
$end =3D $start + $per_page;

//call to the paginator function ...
echo paginator ($current, $total, $per_page, $link, $limit);


//Show the results in different pages
for ($i =3D $start; $i<=3D$end ;$i++)
{
echo $myArray[$i]."
";
}


?>

//-------------------example.php---------------------------- ---------------=
---------------------------------




2009/9/30 Angelo Zanetti

>
> Hi All,
>
> I am looking for a paging script, not the normal type but slightly
> different. It must show as follows:
>
> 1 2 3 ... 12
>
> Then:
>
> 1 ... 678 ... 12
>
> And
>
> 1 ... 10 11 12
>
> I have googled and not really found much and don't really want to reinven=
t
> the wheel. I am sure I can write my own but due to time constraints ill
> like
> to get a script that will assist me.
>
> Thanks in advance
> http://www.wapit.co.za
> http://www.elemental.co.za
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--=20
http://peachep.wordpress.com

--00151761ca582244870474c9bf22--

RE: Paging script

am 30.09.2009 14:06:54 von ANGELO ZANETTI

------=_NextPart_000_0000_01CA41D7.45B95B70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

=20

=20

_____ =20

From: Ruben Crespo [mailto:rumailster@gmail.com]=20
Sent: 30 September 2009 01:23 PM
To: Angelo Zanetti
Cc: php-general@lists.php.net
Subject: Re: [PHP] Paging script

=20

Hi all,

Maybe it is not just what you need but could be helpfull.

Here you have the code:

//-------------------paginator.php-------------------------- -------------=
---
----------------------------------
function paginator ($current, $total, $per_page, $link, $limit) {

if ($current == '')
{
$current =3D 1;
}else{
$current =3D $current;
}
=20
$total_pages =3D ceil($total/$per_page);
$previous =3D $current - 1;
$next =3D $current + 1;
=20

/*traduction*/
$toFrom =3D "

Page ".$current." of ".$total_pages."

";
$Goto =3D "Go to Page";
$go =3D "Go";
=20

$texto =3D "
".$toFrom."
    ";
    =20
    if ($current > 1)
    $texto .=3D "
  • ";
    else
    $texto .=3D "
  • «
  • ";
    =20
    =20
    //Se lista hasta llegar a la posici=F3n actual =20
    if ($current > $limit) {
    $start =3D ($current - $limit) + 1;
    $texto .=3D "
  • ...
  • ";
    } else {
    $start =3D 1;
    }
    =20
    for ($start; $start < $current; $start++) {
    $texto .=3D "
  • ";
    }
    =20
    //mostramos posicion actual
    $texto .=3D "
  • $current
  • ";
    =20
    //mostramos resto de registros
    for ($i=3D$current+1; $i<=3D$total_pages; $i++) {
    =20
    if ($i > $limit)
    {
    $texto .=3D "
  • ...
  • ";
    $i =3D $total_pages;
    }else{
    $texto .=3D "
  • ";
    }
    }
    =20
    if ($current < $total_pages)
    {
    $texto .=3D "
  • ";
    }else{
    $texto .=3D "
  • »
  • ";
    }
    =20
    $texto .=3D "
";=20
=20
=20
//a form to go directly to the page you want=20
$texto .=3D '



'.$Goto.' value=3D"" />




';



$texto .=3D '



';
=20
return $texto;

}

?>
//-------------------paginator.php-------------------------- -------------=
---
----------------------------------

//-------------------example.php---------------------------- -------------=
---
--------------------------------
include ("paginator.php");

for ($n=3D0; $n<=3D100; $n++)
{
$myArray [$n] =3D $n;
}

$total =3D count ($myArray); //the total elements in the array
$per_page =3D 5; //elements the script show
$link =3D "example.php?page=3D"; //link
$limit =3D 3; //number of items you show in the paginator list



if ($_GET["page"])
{
$current =3D $_GET["page"];
}else{
$current =3D $_POST["page"];
}

$start =3D ($current-1) * $per_page;
$end =3D $start + $per_page;

//call to the paginator function ...
echo paginator ($current, $total, $per_page, $link, $limit);


//Show the results in different pages
for ($i =3D $start; $i<=3D$end ;$i++)
{
echo $myArray[$i]."
";
}


?>

//-------------------example.php---------------------------- -------------=
---
--------------------------------


Thanks ruben very much :-)

=20

Regards

Angelo

=20

http://www.wapit.co.za
http://www.elemental.co.za


------=_NextPart_000_0000_01CA41D7.45B95B70--

RE: Paging script

am 30.09.2009 14:11:28 von Mert Oztekin

This should do it. i didnt have time to test so there may be some bugs.


function pageit($limit , $total, $page, $link)
{
$last =3D intval($total / $limit) + ($total % $limit ==0 ? 0:1)=
;
if(!is_numeric($page) || $page > $last)
$page =3D 1;

$pages[] =3D 1;

if($page == 1)
{
$pages[] =3D 2;
$pages[] =3D 3;
}
else
if($page == $last)
{
$pages[]=3D $last - 2;
$pages[] =3D $last -1;
}
else
{
if($page - 1 > 1)
$pages[] =3D $page -1;
$pages[] =3D $page;
if($page +1 < $last)
$pages[] =3D $page +1;

}

$pages[] =3D $last;

for($i=3D0; $i < count($pages) ; $i++)
{
if($pages[$i] <1 || $pages[$i] > $last)
continue;
if($i>0)
if($pages[$i] - $pages[$i-1] > 1 )
echo '...';
echo '' =
.. $pages[$i] . '
';
}
}




-----Original Message-----
From: Angelo Zanetti [mailto:angelo@elemental.co.za]
Sent: Wednesday, September 30, 2009 1:59 PM
To: Mert Oztekin; php-general@lists.php.net
Subject: RE: [PHP] Paging script



-----Original Message-----
From: Mert Oztekin [mailto:moztekin@anadolusigorta.com.tr]
Sent: 30 September 2009 12:40 PM
To: 'Angelo Zanetti'; php-general@lists.php.net
Subject: RE: [PHP] Paging script

Sorry but I dont understand what you mean. Can you be more specific?

{1} 2 3 ... 12 (Startup / Total 12 pages)
When you click 7
1 ... 6 {7} 8 ... 12
When you click 11 or 12
1 ... 10 11 {12}

Do you mean something like this?


Hi Mert,

Yes I mean exactly like you have it there,

Regards
Angelo



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir v=
e gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendirin=
iz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili o=
larak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketi=
miz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?nda=
n, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bil=
gisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individu=
al(s) stated in this message. If you received this message in error, please=
immediately notify the sender and delete it from your system. Our company =
has no legal responsibility for the contents of the message and its attachm=
ents. Our company shall have no liability for any changes or late receiving=
, loss of integrity and confidentiality, viruses and any damages caused in =
anyway to your computer system.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Paging script

am 30.09.2009 15:09:50 von Ruben Crespo

--0015175d0640fcfa440474cb3ed1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

O.K Angelo,

I wish you that you find the code useful for your projects.

Best Regards !!

Rub=E9n Crespo

2009/9/30 Angelo Zanetti

>
>
>
>
> _____
>
> From: Ruben Crespo [mailto:rumailster@gmail.com]
> Sent: 30 September 2009 01:23 PM
> To: Angelo Zanetti
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Paging script
>
>
>
> Hi all,
>
> Maybe it is not just what you need but could be helpfull.
>
> Here you have the code:
>
>
> //-------------------paginator.php-------------------------- -------------=
---
> ----------------------------------
> > function paginator ($current, $total, $per_page, $link, $limit) {
>
> if ($current == '')
> {
> $current =3D 1;
> }else{
> $current =3D $current;
> }
>
> $total_pages =3D ceil($total/$per_page);
> $previous =3D $current - 1;
> $next =3D $current + 1;
>
>
> /*traduction*/
> $toFrom =3D "

Page ".$current." of ".$total_pages."

";
> $Goto =3D "Go to Page";
> $go =3D "Go";
>
>
> $texto =3D "
>
".$toFrom."
>
    ";
    >
    > if ($current > 1)
    > $texto .=3D "
  • ";
    > else
    > $texto .=3D "
  • «
  • ";
    >
    >
    > //Se lista hasta llegar a la posici=F3n actual
    > if ($current > $limit) {
    > $start =3D ($current - $limit) + 1;
    > $texto .=3D "
  • ...
  • ";
    > } else {
    > $start =3D 1;
    > }
    >
    > for ($start; $start < $current; $start++) {
    > $texto .=3D "
  • ";
    > }
    >
    > //mostramos posicion actual
    > $texto .=3D "
  • $current
  • ";
    >
    > //mostramos resto de registros
    > for ($i=3D$current+1; $i<=3D$total_pages; $i++) {
    >
    > if ($i > $limit)
    > {
    > $texto .=3D "
  • ...
  • ";
    > $i =3D $total_pages;
    > }else{
    > $texto .=3D "
  • ";
    > }
    > }
    >
    > if ($current < $total_pages)
    > {
    > $texto .=3D "
  • ";
    > }else{
    > $texto .=3D "
  • »
  • ";
    > }
    >
    > $texto .=3D "
";
>
>
> //a form to go directly to the page you want
> $texto .=3D '
>

>

>

>

'.$Goto.' ue=3D"" />
>


>

>

>
';
>
>
>
> $texto .=3D '

>
>

> ';
>
> return $texto;
>
> }
>
> ?>
>
> //-------------------paginator.php-------------------------- -------------=
---
> ----------------------------------
>
>
> //-------------------example.php---------------------------- -------------=
---
> --------------------------------
> > include ("paginator.php");
>
> for ($n=3D0; $n<=3D100; $n++)
> {
> $myArray [$n] =3D $n;
> }
>
> $total =3D count ($myArray); //the total elements in the array
> $per_page =3D 5; //elements the script show
> $link =3D "example.php?page=3D"; //link
> $limit =3D 3; //number of items you show in the paginator list
>
>
>
> if ($_GET["page"])
> {
> $current =3D $_GET["page"];
> }else{
> $current =3D $_POST["page"];
> }
>
> $start =3D ($current-1) * $per_page;
> $end =3D $start + $per_page;
>
> //call to the paginator function ...
> echo paginator ($current, $total, $per_page, $link, $limit);
>
>
> //Show the results in different pages
> for ($i =3D $start; $i<=3D$end ;$i++)
> {
> echo $myArray[$i]."
";
> }
>
>
> ?>
>
>
> //-------------------example.php---------------------------- -------------=
---
> --------------------------------
>
>
> Thanks ruben very much :-)
>
>
>
> Regards
>
> Angelo
>
>
>
> http://www.wapit.co.za
> http://www.elemental.co.za
>
>


--=20
http://peachep.wordpress.com

--0015175d0640fcfa440474cb3ed1--