Page system help.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Is it possible to add a page system like:

"< 1-2-3-4-5 >"   or  "<PREV - NEXT>

To a page thats already written out, or will it be too much work?

For example:

5 articles per page (homepage)... If someone wanted to see the previous
5 articles they could click the "see last 5" or "older posts"  instead
of looking through the archive.

Because I put an image with every post. That would waste serious
bandwidth to load every article at once.

Too see what I am talking about, check my site at

Im looking for a simple solution, any help would be appreciated though.


Re: Page system help.

Mike написав:
Quoted text here. Click to load it

 In order to make this script flexible you have to find a way to order
your articles. For example it could be done using MySql. You just
regard each article as a record in corresponding table in mysql.  The
simple SQL for such table is as follows:

  `id` tinyint(4) NOT NULL auto_increment,
  `titla` varchar(40) NOT NULL default '',
  `text` text NOT NULL,
  `date` date NOT NULL default '0000-00-00',
  `picture` varchar(40) NOT NULL default '',
  PRIMARY KEY  (`id`)

The powerfull tool in MySQl is to make "limits" queries. For example
the following query:
   select * from `news` limit 0,5
 means that you will receive 5 records starting with 0.

Now lets generate the line <1-2-3-4-5> for page system. At first we
have to calculate the total number of articles.
     $res=mysq_query("select cound(id) as count from `news`") or
die("Query failed: " . mysql_error());;
   // now the variable $count["count"] contains  our information
   // let $page be global variable for the page where we stopped at the

  if (!isset($page)) $page=1;

  if ($page>5)
        echo("<a href=\"index.php?page=$pp\">Prev</a>");
  for ($i=0;$i<5;$i++)
        echo("<a href="\index.php?page=$pp\">$pp</a>");

  if ($page+4<$count["count"])
      echo("<a href=\"index.php?page=$pp\">Prev</a>");

  // and at last mysq - query

  $res=mysql_query("select * from `news` order by  `id` desc limit
$page , 1");

Re: Page system help.

Quoted text here. Click to load it

"Error 403: Forbidden!

The server understood the request, but is refusing to fulfill it.
Authorization will not help and the request SHOULD NOT be repeated.
Locate your Mobile phone: <
Great gifts: <

Site Timeline