im stuck with being on a busy road with alot of traffic all the time 🙁
that str thingy is for a script im making, to display multiple pages if there are a certain amount of rows in the db, should be good when ive finished it... got a script already, but i dont understand it, also i would prefer to make it myself anyway 🙂
==edit==
heres teh code that i thought id post (not mine, but the other one, could you help me with decifering it please 🙂
<?php
/* $Id: multipage.php,v 1.6 2002/09/28 08:01:41 shaggy Exp $ */
/*
Copyright (c) 2001, 2002 by Martin Tsachev. All rights reserved.
mailto:martin@f2o.org
[url]http://martin.f2o.org[/url]
Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the conditions available at
[url]http://www.opensource.org/licenses/bsd-license.html[/url]
are met.
*/
class MultiPage {
var $db; // PEAR::DB object
var $uri; // base URI of the current page
var $sep;
var $limit; // max results per page
var $maxpages = 20; // max number of page links
var $start; // start row
var $rows; // number of rows
var $pages; // number of pages
var $prev;
var $next;
// the last part of the URI, determines the start row if numeric
// this ways instead of /php/?start=15 you can have /php/15
var $uri_tail;
function MultiPage(&$db, $uri, $rows, $sql, $limit = 15, $results = 'Results') {
$this->db = $db;
$this->sql = $sql;
$this->rows = $rows;
$this->limit = $limit;
$this->results = $results;
$this->uri_tail = $GLOBALS['filename'];
$this->uri = $uri;
if (strstr($this->uri, '?')) {
$this->sep = ini_get('arg_separator.output') . 'start=';
} elseif ($this->uri_tail == '' or $this->uri_tail > 0){
$this->sep = '';
} else {
$this->sep = '?start=';
}
$this->buildData();
}
function buildData() {
$this->start = isset($_GET['start']) ? (int) $_GET['start'] : (int) $this->uri_tail;
if ($this->start < 0) {
$this->start = 0;
}
if ($this->start >= $this->rows) {
$this->start = $this->rows - $this->limit;
}
$this->from = $this->start + 1;
$this->to = $this->start + $this->limit;
if ($this->to > $this->rows) {
$this->to = $this->rows;
}
$this->pages = ceil($this->rows / $this->limit);
$this->page = ceil($this->start / $this->limit) + 1;
if ($this->page > $this->pages) {
$this->page = $this->pages;
}
$this->prev = $this->start - $this->limit;
$this->prev = ($this->prev >= 0) ? $this->prev : null;
$this->next = $this->start + $this->limit;
$this->next = ($this->next < $this->rows) ? $this->next : null;
}
function &getResult() {
return $this->db->limitQuery($this->sql, $this->start, $this->limit);
}
function link($param) {
if ($param) {
return ($this->uri . $this->sep . $param);
}
return $this->uri;
}
function getNav() {
$html = '';
if (is_int($this->prev)) {
$html .= '<a href="' . $this->link($this->prev) . '">Previous</a>';
} else {
$html .= 'Previous';
}
$html .= ' | ';
$radio = floor($this->maxpages / 2);
$minpage = $this->page - $radio;
if ($minpage < 1) {
$minpage = 1;
}
$maxpage = $this->page + $radio - 1;
if ($maxpage > $this->pages) {
$maxpage = $this->pages;
}
foreach (range($minpage, $maxpage) as $i) {
$offset = $this->limit * ($i - 1);
if ($this->start == $offset) {
$html .= " $i ";
} else {
$html .= ' <a href="' . $this->link($offset) . '">' . "$i</a> ";
}
}
$html .= ' | ';
if (is_int($this->next)) {
$html .= '<a href="' . $this->link($this->next) . '">Next</a>';
} else {
$html .= 'Next';
}
return $html;
}
function getHeader() {
return "$this->results $this->from - $this->to of $this->rows. ";
}
} // end class MultiPage
?>