Or try the attached code
Nikos
----- Original Message -----
From: "Maxim Maletsky" <[EMAIL PROTECTED]>
To: "Shahar Tal" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, February 02, 2003 7:30 PM
Subject: Re: [PHP-DB] page splitting
>
> you should get a class that does that. PHP Classes (phpclasses.org) is a
> good place to start
>
> --
> Maxim Maletsky
> [EMAIL PROTECTED]
>
>
> On Sun, 2 Feb 2003 17:37:12 +0200 "Shahar Tal" <[EMAIL PROTECTED]>
wrote:
>
> > Hello all!
> >
> > First of all i'd like to say thanks. many of you helped me here a lot,
and I
> > can't thank you enough for it.
> >
> > For my next question.
> > I have a query. it takes up all the rows from a certain database, and
> > displays them.
> > I want to do the simple thing, page splitting. make it show a certain
number
> > of records everytime, let's say, 10, and then
> > automatically show the links like [<<] 1 2 3 [>>] to move between the
pages.
> >
> > I'm looking for the most simple and easy way to do it, as it should be a
> > very easy thing to do.
> >
> > Thank you all, once again :)
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
<?
$conn=mysql_connect($hostname, $user, $pass);
$rows_per_page=20;
$sql="SELECT * FROM table";
$result=mysql_db_query($database, $sql, $conn) or Die (mysql_error());
$total_records=mysql_num_rows($result);
$pages=ceil($total_records / $rows_per_page);
mysql_free_result($result);
?>
<html code>
<?
if (!isset($screen)) $screen=0;
$start=$screen * $rows_per_page;
$sql="SELECT col1, col2, ... FROM table";
$sql.="LIMIT $start, $rows_per_page";
$result=mysql_db_query($database, $sql, $conn) or Die (mysql_error());
while (list($col1, $clo2, ...)=mysql_fetch_row($result)) {
echo "....";
}
if ($screen>0) {
$url="$PHP_SELF?screen=$screen-1;
echo "<a href=\"$url\"> << </a>\n";
}
for ($i=0; $i<$pages; $i++) {
$I=$i+1;
$url="$PHP_SELF?screen=" . $i;
echo "<a href=\"$url\">".$I."</a>";
}
if ($screen < $pages-1) {
$url="$PHP_SELF?screen=";
$url .= $screen+1;
echo "<a href=\"$url\" class=\"menu3\"> >> </a>";
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php