Code: Select all
class pagination{
var $foo;
function output(){
global $foo;
print $foo;
}
}
Code: Select all
$p->foo = "blahblah";
$p->output();
Any suggestions?
Moderator: General Moderators
Code: Select all
class pagination{
var $foo;
function output(){
global $foo;
print $foo;
}
}
Code: Select all
$p->foo = "blahblah";
$p->output();
Code: Select all
class pagination{
public $foo;
function output(){
$foo = $this -> foo;
echo $foo;
}
}Code: Select all
class pagination{
public $page_table;
public $per_page;
function output(){
$page_table = $this->page_table;
$per_page = $this->per_page;
//The Query
$page_query = mysql_query("SELECT id FROM $page_table");
//Stores total number of results
$num = mysql_num_rows($page_query);
//Divides the number of results by the number per page
$pages = $num / $per_page;
//Sets the increment value at 1
$i = "1";
//The Output
print '<div class="pagination">';
print '<a href=""><</a>';
while($i <= $pages):
print '<a href="'.$php_self.'?page='.$i.'">'.$i.'</a>';
$i++;
endwhile;
print '<a href="">></a>';
print '</div>';
}
}Code: Select all
<?php
$p->page_table = "module_members";
$p->per_page = "12";
$p->output();
?>Code: Select all
<?php
class Pagination {
protected $config;
public function setConfig($config) {
$this -> config = $config;
}
public function output() {
$page_table = $this -> config['page_table'];
$per_page = $this -> config['per_page'];
...
}
}
$config = array(
'page_table' => $page_table,
'per_page' => 10
);
$pagination = new Pagination();
$pagination -> setConfig($config);Code: Select all
<?php
class Pagination {
protected $config;
public function __construct($config = null) {
$this -> setConfig($config);
}
public function setConfig($config) {...}
public function output() {...}
}
$config = array(
'page_table' => $page_table,
'per_page' => 10
);
$pagination = new Pagination($config);Code: Select all
$result = mysql_query("SELECT COUNT(*) AS count FROM " . $page_table);
$row = mysql_fetch_array($result);
$num = current($row);Code: Select all
<?php
class Pagination {
public function __construct($config = null) {...}
public function setConfig($config) {...}
public function output(){
$i = 1;
$output = '<div class="pagination">'
. '<a href=""><</a>';
while($i <= $pages):
$output .= '<a href="'.$php_self.'?page='.$i.'">'.$i.'</a>';
$i++;
endwhile;
$output .= '<a href="">></a>'
. '</div>';
return $output;
}
}
$config = array(
'page_table' => $page_table,
'per_page' => 10
);
$pagination = new Pagination($config);
echo $pagination -> output(); // Output is echoed here